aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/documentmodel
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2022-03-11 09:41:24 +0000
committerArne H Juul <arnej@yahooinc.com>2022-03-11 13:18:26 +0000
commit994196c5354c02f40c223cf4fe3388aba09ea020 (patch)
tree3a063183b55e37b69a41ba89aa015a287c1cb6a8 /config-model/src/main/java/com/yahoo/documentmodel
parenta943db2029d7b78eb3dca70bf5a6a4377d9ae743 (diff)
ensure unique ReferenceDataType instances
Diffstat (limited to 'config-model/src/main/java/com/yahoo/documentmodel')
-rw-r--r--config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java16
1 files changed, 16 insertions, 0 deletions
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 d98869e9dd3..4ff54d7ff1c 100644
--- a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java
+++ b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java
@@ -4,8 +4,10 @@ package com.yahoo.documentmodel;
import com.yahoo.document.DataType;
import com.yahoo.document.Document;
import com.yahoo.document.Field;
+import com.yahoo.document.ReferenceDataType;
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;
@@ -383,4 +385,18 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp
}
+ private ReferenceDataType refToThis = null;
+
+ @SuppressWarnings("deprecation")
+ public ReferenceDataType getReferenceDataType() {
+ if (refToThis == null) {
+ // super ugly, the APIs for this are horribly inconsistent
+ var tmptmp = TemporaryStructuredDataType.create(getName());
+ var tmp = ReferenceDataType.createWithInferredId(tmptmp);
+ tmp.setTargetType((StructuredDataType) this);
+ refToThis = tmp;
+ }
+ return refToThis;
+ }
+
}