@Override public boolean equals(Object o) { return ((o instanceof StructuredDataType) && super.equals(o)); }
/** Two fields are equal if they have the same name and the same data type */ @Override public boolean equals(Object o) { return this == o || o instanceof Field && super.equals(o) && dataType.equals(((Field) o).dataType); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof CompositeFieldValue)) return false; if (!super.equals(o)) return false; CompositeFieldValue that = (CompositeFieldValue) o; if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null) return false; return true; }
@Override public boolean equals(Object rhs) { return super.equals(rhs) && (rhs instanceof ReferenceDataType) && targetType.equals(((ReferenceDataType) rhs).targetType); } }
private static boolean isSupportedPositionType(DataType dataType) { if (dataType instanceof ArrayDataType) { dataType = ((ArrayDataType)dataType).getNestedType(); } return dataType.equals(PositionDataType.INSTANCE); }
private boolean compatibleTypes(DataType summaryType, DataType existingType) { if (summaryType instanceof TensorDataType && existingType instanceof TensorDataType) { return summaryType.isAssignableFrom(existingType); // TODO: Just do this for all types } return summaryType.equals(existingType); }
public static <T> T getFieldValue(FieldValue struct, DataType structType, Field field, Class<T> fieldType) { if (!(struct instanceof Struct)) { return null; } if (!struct.getDataType().equals(structType)) { return null; } FieldValue fieldValue = ((Struct)struct).getFieldValue(field); if (!fieldType.isInstance(fieldValue)) { return null; } return fieldType.cast(fieldValue); }
@SuppressWarnings("deprecation") @Override public void setDataType(DataType type) { if (type.equals(DataType.URI)) { // Different defaults, naturally normalizing.inferLowercase(); stemming=Stemming.NONE; } this.dataType = type; if (!idOverride) { this.fieldId = calculateIdV7(null); } }
public static FieldValue readAtomic(String field, DataType expectedType) { if (expectedType.equals(DataType.RAW)) { return expectedType.createFieldValue(new Base64().decode(field)); } else if (expectedType.equals(PositionDataType.INSTANCE)) { return PositionDataType.fromString(field); } else if (expectedType instanceof ReferenceDataType) { return readReferenceFieldValue(field, expectedType); } else { return expectedType.createFieldValue(field); } }
@Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; for (SDField field : search.allConcreteFields()) { if ( ! field.getDataType().equals(DataType.URI)) continue; if (field.doesAttributing()) throw new IllegalArgumentException("Error in " + field + " in " + search + ": " + "uri type fields cannot be attributes"); } }
private void assignPositionFieldFromStringIfNonEmpty(Struct value, String elementText, boolean base64) { String str = base64 ? Utf8.toString(new Base64().decode(elementText)) : elementText; str = str.trim(); if (str.isEmpty()) { return; } DataType valueType = value.getDataType(); if (valueType.equals(PositionDataType.INSTANCE)) { value.assign(PositionDataType.fromString(str)); } }
@Override protected void checkCompatibility(DataType fieldType) { if (value != null && !value.getDataType().equals(fieldType)) { throw new IllegalArgumentException("Expected " + fieldType.getName() + ", got " + value.getDataType().getName()); } }
private void assignFromFieldValue(ReferenceFieldValue rhs) { if (!getDataType().equals(rhs.getDataType())) { throw new IllegalArgumentException(String.format( "Can't assign reference of type %s to reference of type %s", rhs.getDataType().getName(), getDataType().getName())); } rhs.getDocumentId().ifPresent(this::setDocumentId); }
@Override protected void checkCompatibility(DataType fieldType) { if (!(fieldType instanceof CollectionDataType)) { throw new UnsupportedOperationException("Expected collection, got " + fieldType.getName() + "."); } fieldType = ((CollectionDataType)fieldType).getNestedType(); if (value != null && !value.getDataType().equals(fieldType)) { throw new IllegalArgumentException("Expected " + fieldType.getName() + ", got " + value.getDataType().getName()); } }
@Override protected void doVerify(VerificationContext context) { DataType next = context.getValue(); DataType prev = context.getVariable(varName); if (prev != null && !prev.equals(next)) { throw new VerificationException(this, "Attempting to assign conflicting types to variable '" + varName + "', " + prev.getName() + " vs " + next.getName() + "."); } context.setVariable(varName, next); }
private static void addAnnotationTypePayloads(DocumentmanagerConfig config, DocumentTypeManager manager) { for (DocumentmanagerConfig.Annotationtype annType : config.annotationtype()) { AnnotationType annotationType = manager.getAnnotationTypeRegistry().getType(annType.id()); DataType payload = manager.getDataType(annType.datatype(), ""); if (!payload.equals(DataType.NONE)) { annotationType.setDataType(payload); } } }
private void assertConsistentTypes(SummaryField existing, SummaryField seen) { if (existing.getDataType() instanceof WeightedSetDataType && seen.getDataType() instanceof WeightedSetDataType && ((WeightedSetDataType)existing.getDataType()).getNestedType().equals(((WeightedSetDataType)seen.getDataType()).getNestedType())) return; // Disregard create-if-nonexistent and create-if-zero distinction if ( ! compatibleTypes(seen.getDataType(), existing.getDataType())) throw new IllegalArgumentException(existing.toLocateString() + " is inconsistent with " + seen.toLocateString() + ": All declarations of the same summary field must have the same type"); }