summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/documentmodel/OwnedStructDataType.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/main/java/com/yahoo/documentmodel/OwnedStructDataType.java')
-rw-r--r--config-model/src/main/java/com/yahoo/documentmodel/OwnedStructDataType.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/config-model/src/main/java/com/yahoo/documentmodel/OwnedStructDataType.java b/config-model/src/main/java/com/yahoo/documentmodel/OwnedStructDataType.java
new file mode 100644
index 00000000000..761a1f0963c
--- /dev/null
+++ b/config-model/src/main/java/com/yahoo/documentmodel/OwnedStructDataType.java
@@ -0,0 +1,56 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.documentmodel;
+
+import com.yahoo.document.DocumentType;
+import com.yahoo.document.StructDataType;
+
+/**
+ * Model for StructDataType declared in a specific document
+ *
+ * @author arnej
+ **/
+public final class OwnedStructDataType extends StructDataType implements OwnedType {
+
+ private final String ownerName;
+ private final String uniqueName;
+ private boolean overrideId = false;
+
+ public OwnedStructDataType(String name, DocumentType document) {
+ this(name, document.getName());
+ }
+
+ public OwnedStructDataType(String name, String owner) {
+ super(name);
+ this.ownerName = owner;
+ this.uniqueName = name + "@" + owner;
+ }
+
+ public void enableOverride() {
+ this.overrideId = true;
+ }
+
+ @Override
+ public String getOwnerName() {
+ return ownerName;
+ }
+
+ @Override
+ public String getUniqueName() {
+ return uniqueName;
+ }
+
+ @Override
+ public String getName() {
+ return overrideId ? uniqueName : super.getName();
+ }
+
+ @Override
+ public int getId() {
+ return overrideId ? getUniqueId() : super.getId();
+ }
+
+ @Override
+ public String toString() {
+ return "{OwnedStructDataType "+uniqueName+" id="+getId()+" uid="+getUniqueId()+" enable override="+overrideId+"}";
+ }
+}