use of com.yahoo.document.TemporaryStructuredDataType in project vespa by vespa-engine.
the class DocumentModelBuilder method resolveTemporariesRecurse.
@SuppressWarnings("deprecation")
private static DataType resolveTemporariesRecurse(DataType type, DataTypeCollection repo, Collection<NewDocumentType> docs) {
if (type instanceof TemporaryStructuredDataType) {
NewDocumentType docType = getDocumentType(docs, type.getId());
if (docType != null) {
type = docType;
return type;
}
DataType real = repo.getDataType(type.getId());
if (real == null) {
throw new NullPointerException("Can not find type '" + type.toString() + "', impossible.");
}
type = real;
} else if (type instanceof StructDataType) {
StructDataType dt = (StructDataType) type;
for (com.yahoo.document.Field field : dt.getFields()) {
if (field.getDataType() != type) {
// XXX deprecated:
field.setDataType(resolveTemporariesRecurse(field.getDataType(), repo, docs));
}
}
} else if (type instanceof MapDataType) {
MapDataType t = (MapDataType) type;
t.setKeyType(resolveTemporariesRecurse(t.getKeyType(), repo, docs));
t.setValueType(resolveTemporariesRecurse(t.getValueType(), repo, docs));
} else if (type instanceof CollectionDataType) {
CollectionDataType t = (CollectionDataType) type;
t.setNestedType(resolveTemporariesRecurse(t.getNestedType(), repo, docs));
} else if (type instanceof ReferenceDataType) {
ReferenceDataType t = (ReferenceDataType) type;
if (t.getTargetType() instanceof TemporaryStructuredDataType) {
DataType targetType = resolveTemporariesRecurse(t.getTargetType(), repo, docs);
t.setTargetType((StructuredDataType) targetType);
}
}
return type;
}
Aggregations