use of com.yahoo.document.datatypes.StructuredFieldValue in project vespa by vespa-engine.
the class CompositeReader method populateComposite.
// TODO createComposite is extremely similar to add/remove, refactor
// yes, this suppresswarnings ugliness is by intention, the code relies on the contracts in the builders
@SuppressWarnings({ "cast", "rawtypes" })
public static void populateComposite(TokenBuffer buffer, FieldValue fieldValue) {
JsonToken token = buffer.currentToken();
if ((token != JsonToken.START_OBJECT) && (token != JsonToken.START_ARRAY)) {
throw new IllegalArgumentException("Expected '[' or '{'. Got '" + token + "'.");
}
if (fieldValue instanceof CollectionFieldValue) {
DataType valueType = ((CollectionFieldValue) fieldValue).getDataType().getNestedType();
if (fieldValue instanceof WeightedSet) {
fillWeightedSet(buffer, valueType, (WeightedSet) fieldValue);
} else {
fillArray(buffer, (CollectionFieldValue) fieldValue, valueType);
}
} else if (fieldValue instanceof MapFieldValue) {
MapReader.fillMap(buffer, (MapFieldValue) fieldValue);
} else if (fieldValue instanceof StructuredFieldValue) {
StructReader.fillStruct(buffer, (StructuredFieldValue) fieldValue);
} else if (fieldValue instanceof TensorFieldValue) {
TensorReader.fillTensor(buffer, (TensorFieldValue) fieldValue);
} else {
throw new IllegalStateException("Has created a composite field" + " value the reader does not know how to handle: " + fieldValue.getClass().getName() + " This is a bug. token = " + token);
}
expectCompositeEnd(buffer.currentToken());
}
Aggregations