private static Object[] checkValuesForType(Property property, Operation operation, @Nullable Object[] values) { if (values == null) { if (operation == Operation.IS_NULL || operation == Operation.IS_NOT_NULL) { return null; } else { throw new IllegalArgumentException("This operation requires non-null values."); } } for (int i = 0; i < values.length; i++) { values[i] = checkValueForType(property, values[i]); } return values; }
public PropertyCondition(Property property, Operation operation, @Nullable Object[] values) { super(checkValuesForType(property, operation, values)); this.property = property; this.operation = operation; }
/** Creates an "less than ('<')" condition for this property. */ public QueryCondition lt(Object value) { return new PropertyCondition(this, Operation.LESS_THAN, value); }
/** Creates an "greater than ('>')" condition for this property. */ public QueryCondition gt(Object value) { return new PropertyCondition(this, Operation.GREATER_THAN, value); }
/** Creates an "IN (..., ..., ...)" condition for this property. */ public QueryCondition in(Object... inValues) { return new PropertyCondition(this, Operation.IN, inValues); }
/** Creates an "not equal ('<>')" condition for this property. */ public QueryCondition notEq(Object value) { return new PropertyCondition(this, Operation.NOT_EQUALS, value); }
/** Creates an "equal ('=')" condition for this property. */ public QueryCondition eq(Object value) { return new PropertyCondition(this, Operation.EQUALS, value); }
/** Creates an "IS NOT NULL" condition for this property. */ public QueryCondition isNotNull() { return new PropertyCondition(this, Operation.IS_NOT_NULL, null); }
public PropertyCondition(Property property, Operation operation, @Nullable Object value) { super(checkValueForType(property, value)); this.property = property; this.operation = operation; }
/** Creates an "IS NULL" condition for this property. */ public QueryCondition isNull() { return new PropertyCondition(this, Operation.IS_NULL, null); }
/** * @see io.objectbox.query.QueryBuilder#contains(Property, String) */ public QueryCondition contains(String value) { return new PropertyCondition(this, Operation.CONTAINS, value); }
/** Creates an "BETWEEN ... AND ..." condition for this property. */ public QueryCondition between(Object value1, Object value2) { Object[] values = {value1, value2}; return new PropertyCondition(this, Operation.BETWEEN, values); }
/** * @see io.objectbox.query.QueryBuilder#startsWith(Property, String) */ public QueryCondition startsWith(String value) { return new PropertyCondition(this, Operation.STARTS_WITH, value); }
/** * @see io.objectbox.query.QueryBuilder#endsWith(Property, String) */ public QueryCondition endsWith(String value) { return new PropertyCondition(this, Operation.ENDS_WITH, value); }