summaryrefslogtreecommitdiffstats
path: root/vespa-documentgen-plugin
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@yahoo-inc.com>2017-02-08 16:49:42 +0100
committerTor Brede Vekterli <vekterli@yahoo-inc.com>2017-02-08 17:02:28 +0100
commitfa231dadff889cccd3b1b2f1a1883d5c20f2dc59 (patch)
tree6530590b7a669c44ea051bf04b472ba985677164 /vespa-documentgen-plugin
parent27ddf647d881ab58ae69dd629599b52ee7c9d320 (diff)
Support references in concrete document types
Diffstat (limited to 'vespa-documentgen-plugin')
-rw-r--r--vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java b/vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java
index a1ba05eacb3..67627ca9410 100644
--- a/vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java
+++ b/vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java
@@ -330,7 +330,8 @@ public class DocumentGenMojo extends AbstractMojo {
out.write("}\n");
annotationTypes.put(annType.getName(), packageName+".annotation."+className);
} catch (IOException e) {
- throw new RuntimeException("Could not export sources for annotation type '"+annType.getName()+"'", e); }
+ throw new RuntimeException("Could not export sources for annotation type '"+annType.getName()+"'", e);
+ }
}
/**
@@ -837,6 +838,9 @@ public class DocumentGenMojo extends AbstractMojo {
if (dt instanceof ArrayDataType) return "java.util.List<"+toJavaType(((ArrayDataType)dt).getNestedType())+">";
if (dt instanceof MapDataType) return "java.util.Map<"+toJavaType(((MapDataType)dt).getKeyType())+","+toJavaType(((MapDataType)dt).getValueType())+">";
if (dt instanceof AnnotationReferenceDataType) return className(((AnnotationReferenceDataType) dt).getAnnotationType().getName());
+ if (dt instanceof ReferenceDataType) {
+ return "com.yahoo.document.DocumentId";
+ }
return "byte[]";
}
@@ -862,6 +866,11 @@ public class DocumentGenMojo extends AbstractMojo {
// For annotation references and generated types, the references are to the actual objects of the correct types, so most likely this is never needed,
// but there might be scenarios where we want to look up the AnnotationType in the AnnotationTypeRegistry here instead.
if (dt instanceof AnnotationReferenceDataType) return "new com.yahoo.document.annotation.AnnotationReferenceDataType(new com.yahoo.document.annotation.AnnotationType(\""+((AnnotationReferenceDataType)dt).getAnnotationType().getName()+"\"))";
+ if (dt instanceof ReferenceDataType) {
+ // All concrete document types have a public `type` constant with their DocumentType.
+ return String.format("new com.yahoo.document.ReferenceDataType(%s.type, %d)",
+ className(((ReferenceDataType) dt).getTargetType().getName()), dt.getId());
+ }
return "DataType.RAW";
}