boolean equalsWithSameKey(SubDocAttribute other) { assert other.getKey().equals(this.getKey()); return this.type.equals(other.type); }
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 @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()); }
@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); }
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); }