/** * Creates a field path from the given field path string. * * @param fieldPathString a string containing the field path * @return Returns a valid field path, parsed from the string */ public FieldPath buildFieldPath(String fieldPathString) { if (fieldPathString.length() > 0) { throw new IllegalArgumentException("Datatype " + toString() + " does not support further recursive structure: " + fieldPathString); } return new FieldPath(); }
private static void extractNestedTypes(NewDocumentType dt, DataType type) { if (type instanceof StructDataType) { StructDataType tmp = (StructDataType) type; extractDataTypesFromFields(dt, tmp.getFieldsThisTypeOnly()); } else if (type instanceof DocumentType) { throw new IllegalArgumentException("Can not handle nested document definitions. In document type '" + dt.getName().toString() + "', we can not define document type '" + type.toString()); } else if (type instanceof CollectionDataType) { CollectionDataType tmp = (CollectionDataType) type; extractNestedTypes(dt, tmp.getNestedType()); addType(dt, tmp.getNestedType()); } else if (type instanceof MapDataType) { MapDataType tmp = (MapDataType) type; extractNestedTypes(dt, tmp.getKeyType()); extractNestedTypes(dt, tmp.getValueType()); addType(dt, tmp.getKeyType()); addType(dt, tmp.getValueType()); } else if (type instanceof TemporaryAnnotationReferenceDataType) { throw new IllegalArgumentException(type.toString()); } } private static boolean testAddType(NewDocumentType dt, DataType type) { return internalAddType(dt, type, true); }
private void ensureSummaryField(DocumentSummary summary, String fieldName, DataType dataType, Source source, SummaryTransform transform) { SummaryField oldField = search.getSummaryField(fieldName); if (oldField == null) { SummaryField newField = new SummaryField(fieldName, dataType, transform); newField.addSource(source); summary.add(newField); return; } if (!oldField.getDataType().equals(dataType)) { fail(oldField, "exists with type '" + oldField.getDataType().toString() + "', should be of type '" + dataType.toString() + "'"); } if (oldField.getTransform() != transform) { fail(oldField, "has summary transform '" + oldField.getTransform().toString() + "', should have transform '" + transform.toString() + "'"); } if (oldField.getSourceCount() != 1 || !oldField.getSingleSource().equals(source.getName())) { fail(oldField, "has source '" + oldField.getSources().toString() + "', should have source '" + source + "'"); } summary.add(oldField); }
throw new NullPointerException("Can not find type '" + type.toString() + "', impossible.");