diff options
Diffstat (limited to 'config-model/src/main/java/com/yahoo/documentmodel')
6 files changed, 133 insertions, 2 deletions
diff --git a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentReferenceDataType.java b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentReferenceDataType.java index 65c282e01e2..702ab835dd4 100644 --- a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentReferenceDataType.java +++ b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentReferenceDataType.java @@ -5,7 +5,6 @@ import com.yahoo.document.DataType; import com.yahoo.document.DocumentType; import com.yahoo.document.ReferenceDataType; import com.yahoo.document.StructuredDataType; -import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.document.datatypes.FieldValue; import com.yahoo.document.datatypes.ReferenceFieldValue; diff --git a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java index dd8edbdde6c..ff5930f8f6a 100644 --- a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java +++ b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java @@ -7,7 +7,6 @@ import com.yahoo.document.Field; import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.StructDataType; import com.yahoo.document.StructuredDataType; -import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.document.annotation.AnnotationType; import com.yahoo.document.annotation.AnnotationTypeRegistry; import com.yahoo.document.datatypes.FieldValue; 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+"}"; + } +} diff --git a/config-model/src/main/java/com/yahoo/documentmodel/OwnedTemporaryType.java b/config-model/src/main/java/com/yahoo/documentmodel/OwnedTemporaryType.java new file mode 100644 index 00000000000..536c10ee242 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/documentmodel/OwnedTemporaryType.java @@ -0,0 +1,41 @@ +// 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; + +/** + * Proxy for a struct type declared in a specific document + * + * @author arnej + **/ +public final class OwnedTemporaryType extends StructDataType implements OwnedType { + + private final String ownerName; + private final String uniqueName; + + public OwnedTemporaryType(String name, DocumentType document) { + this(name, document.getName()); + } + + public OwnedTemporaryType(String name, String owner) { + super(name); + this.ownerName = owner; + this.uniqueName = name + "@" + owner; + } + + @Override + public String getOwnerName() { + return ownerName; + } + + @Override + public String getUniqueName() { + return uniqueName; + } + + @Override + public String toString() { + return "{OwnedTemporaryType "+uniqueName+" id="+getId()+" uid="+getUniqueId()+"}"; + } +} diff --git a/config-model/src/main/java/com/yahoo/documentmodel/OwnedType.java b/config-model/src/main/java/com/yahoo/documentmodel/OwnedType.java new file mode 100644 index 00000000000..e3a91692ca8 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/documentmodel/OwnedType.java @@ -0,0 +1,15 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.documentmodel; + +/** + * API for a type declared in a specific document + * + * @author arnej + **/ +public interface OwnedType { + String getOwnerName(); + String getUniqueName(); + default int getUniqueId() { + return getUniqueName().hashCode(); + } +} diff --git a/config-model/src/main/java/com/yahoo/documentmodel/TemporaryUnknownType.java b/config-model/src/main/java/com/yahoo/documentmodel/TemporaryUnknownType.java new file mode 100644 index 00000000000..66f6354b3f5 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/documentmodel/TemporaryUnknownType.java @@ -0,0 +1,21 @@ +// 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.StructDataType; + +/** + * Proxy for an unknown type (must resolve to struct or document) + * + * @author arnej + **/ +public final class TemporaryUnknownType extends StructDataType { + + public TemporaryUnknownType(String name) { + super(name); + } + + @Override + public String toString() { + return "{TemporaryUnknownType "+getName()+" id="+getId()+"}"; + } +} |