@Override public Boolean visit(TypeIsQueryCriteria criteria, KVValue<?> arg) { KVValue<?> referenced = resolve(criteria.getAttributeReference(), arg); if (referenced == null) { return false; } ScalarType basicType = ScalarType.fromDocType(referenced.getType()); return criteria.getExpectedType().equals(basicType); }
@Override public int hashCode() { int hash = 3; hash = 67 * hash + this.key.hashCode(); hash = 67 * hash + this.type.hashCode(); return hash; }
boolean equalsWithSameKey(SubDocAttribute other) { assert other.getKey().equals(this.getKey()); return this.type.equals(other.type); }
private SubDocType getSubDocType(KVDocument value) { SubDocType.Builder builder = subDocTypeBuilderProvider.get(); for (DocEntry<?> entry : value) { if (!(entry.getValue() instanceof KVDocument)) { ScalarType type = ScalarType.fromDocType(entry.getValue().getType()); SubDocAttribute att = new SubDocAttribute(entry.getKey(), type); builder.add(att); } } return builder.build(); }
public Builder add(@Nonnull SubDocAttribute att, @Nonnull ScalarValue value) { if (values.containsKey(att.getKey())) { throw new IllegalArgumentException("There is another attribute with " + att.getKey()); } if (!att.getType().equals(value.getType())) { throw new IllegalArgumentException("Type of attribute " + att + " is " + att.getType() + " which is different " + "than the type of the given value (value is " + value + " and its type is " + value.getType()); } values.put(att.getKey(), value); return this; }
@Nullable static QueryCriteria getStructureQueryCriteria(AttributeReference attRef, ScalarType expectedType) { QueryCriteria refQuery = getStructureQueryCriteria(attRef); if (isTypeKnownInStructure(attRef) || expectedType.equals(ScalarType.ARRAY)) { QueryCriteria typeQuery = new TypeIsQueryCriteria(attRef, expectedType); if (refQuery != null) { return new AndQueryCriteria(refQuery, typeQuery); } return typeQuery; } return refQuery; }
@Override public int hashCode() { int hash = 7; hash = 37 * hash + getAttributeReference().hashCode(); hash = 37 * hash + this.expectedType.hashCode(); return hash; }
@Override @Nonnull public Boolean visit(TypeIsQueryCriteria criteria, StructureElement arg) { TriValuedResult<? extends ScalarType> typeResult = AttributeReferenceResolver.resolveScalarType( criteria.getAttributeReference(), arg ); if (typeResult.isUndecidable()) { //it could be any scalar type, but not an array if (criteria.getExpectedType().equals(ScalarType.ARRAY)) { return false; } throw new UndecidableCaseException(criteria, rootStructure); } if (typeResult.isNull()) { return false; } ScalarType type = typeResult.getValue(); return type.equals(criteria.getExpectedType()); }
if (!scalarType1.equals(scalarType2) && scalarType1 != ScalarType.NULL && scalarType2 != ScalarType.NULL) {
@Override public Condition visit(IsEqualQueryCriteria criteria, Boolean inArray) { String[] keys = translateArrayRef(criteria); Field field = DSL.field(databaseInterface.arraySerializer().getFieldName(keys)); Param<?> value; Condition criteriaCondition; if (criteria.getValue().getType().equals(ScalarType.NULL)) { if (!isInArrayValue(criteria.getAttributeReference(), inArray)) { criteriaCondition = field.isNull(); } else { criteriaCondition = field.equal( translateValueToArraySerialization(criteria.getValue()) ); } } else { if (!isInArrayValue(criteria.getAttributeReference(), inArray)) { value = translateValueToSQL(criteria.getValue()); } else { value = translateValueToArraySerialization(criteria.getValue()); } criteriaCondition = field.equal(value); } return addArrayCondition(criteria, criteriaCondition, keys, inArray); }