public ComparingQuery(EntityIndex<O, A> index) { super(index.getAttribute()); }
@Override public Iterable<Object> getValues(Entity object, QueryOptions queryOptions) { return index.getValues(object, queryOptions); } }
/** * Creates an {@link Equal} query which asserts that an attribute equals a certain value. * * @param entityIndex The index to which the query refers * @param attributeValue The value to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link Equal} query */ static <O extends Entity, A> Equal<EntityHandle<O>, A> equal(EntityIndex<O, A> entityIndex, A attributeValue) { return new Equal<>(entityIndex.getAttribute(), attributeValue); }
/** * Creates a {@link StringEndsWith} query which asserts that an attribute ends with a certain string fragment. * * @param entityIndex The index to which the query refers * @param attributeValue The value to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link StringEndsWith} query */ static <O extends Entity, A extends CharSequence> StringEndsWith<EntityHandle<O>, A> endsWith(EntityIndex<O, A> entityIndex, A attributeValue) { return new StringEndsWith<>(entityIndex.getAttribute(), attributeValue); }
/** * Creates a {@link StringContains} query which asserts that an attribute contains with a certain string fragment. * * @param entityIndex The index to which the query refers * @param attributeValue The value to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link StringContains} query */ @Deprecated static <O extends Entity, A extends CharSequence> StringContains<EntityHandle<O>, A> contains(EntityIndex<O, A> entityIndex, A attributeValue) { return new StringContains<>(entityIndex.getAttribute(), attributeValue); }
/** * Creates a {@link StringContains} query which asserts that an attribute contains with a certain string fragment. * * @param entityIndex The index to which the query refers * @param attributeValue The value to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link StringContains} query */ static <O extends Entity, A extends CharSequence> StringContains<EntityHandle<O>, A> contains(EntityIndex<O, A> entityIndex, A attributeValue) { return new StringContains<>(entityIndex.getAttribute(), attributeValue); }
/** * Creates a {@link StringStartsWith} query which asserts that an attribute starts with a certain string fragment. * * @param entityIndex The index to which the query refers * @param attributeValue The value to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link StringStartsWith} query */ static <O extends Entity, A extends CharSequence> StringStartsWith<EntityHandle<O>, A> startsWith(EntityIndex<O, A> entityIndex, A attributeValue) { return new StringStartsWith<>(entityIndex.getAttribute(), attributeValue); }
/** * Creates a {@link StringEndsWith} query which asserts that an attribute ends with a certain string fragment. * * @param entityIndex The index to which the query refers * @param attributeValue The value to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link StringEndsWith} query */ @Deprecated static <O extends Entity, A extends CharSequence> StringEndsWith<EntityHandle<O>, A> endsWith(EntityIndex<O, A> entityIndex, A attributeValue) { return new StringEndsWith<>(entityIndex.getAttribute(), attributeValue); }
/** * Creates an {@link Equal} query which asserts that an attribute equals a certain value. * * @param entityIndex The index to which the query refers * @param attributeValue The value to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link Equal} query */ @Deprecated static <O extends Entity, A> Equal<EntityHandle<O>, A> equal(EntityIndex<O, A> entityIndex, A attributeValue) { return new Equal<>(entityIndex.getAttribute(), attributeValue); }
/** * Creates a {@link StringStartsWith} query which asserts that an attribute starts with a certain string fragment. * * @param entityIndex The index to which the query refers * @param attributeValue The value to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link StringStartsWith} query */ @Deprecated static <O extends Entity, A extends CharSequence> StringStartsWith<EntityHandle<O>, A> startsWith(EntityIndex<O, A> entityIndex, A attributeValue) { return new StringStartsWith<>(entityIndex.getAttribute(), attributeValue); }
/** * Creates a {@link StringIsContainedIn} query which asserts that an attribute is contained in a certain string * fragment. * * @param entityIndex The index to which the query refers * @param attributeValue The value to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link StringStartsWith} query */ static <O extends Entity, A extends CharSequence> StringIsContainedIn<EntityHandle<O>, A> isContainedIn(EntityIndex<O, A> entityIndex, A attributeValue) { return new StringIsContainedIn<>(entityIndex.getAttribute(), attributeValue); }
/** * Creates a {@link Between} query which asserts that an attribute is between a lower and an upper bound. * * @param entityIndex The index to which the query refers * @param lowerValue The lower bound to be asserted by the query * @param lowerInclusive Whether the lower bound is inclusive or not (true for "greater than or equal to") * @param upperValue The upper bound to be asserted by the query * @param upperInclusive Whether the upper bound is inclusive or not (true for "less than or equal to") * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return A {@link GreaterThan} query */ static <O extends Entity, A extends Comparable<A>> Between<EntityHandle<O>, A> between(EntityIndex<O, A> entityIndex, A lowerValue, boolean lowerInclusive, A upperValue, boolean upperInclusive) { return new Between<>(entityIndex.getAttribute(), lowerValue, lowerInclusive, upperValue, upperInclusive); }
/** * Creates an {@link AttributeOrder} object which pairs an attribute with a preference to sort results by that * attribute in descending order. These {@code AttributeOrder} objects can then be passed to the * {@link #orderBy(com.googlecode.cqengine.query.option.AttributeOrder[])} method to create a query option which * sorts results by the indicated attributes and ascending/descending preferences. * * @param entityIndex An attribute to sort by * @param <O> The type of the object containing the attributes * @return An {@link AttributeOrder} object, encapsulating the attribute and a preference to sort results by it * in descending order */ static <O extends Entity> AttributeOrder<EntityHandle<O>> descending(EntityIndex<O, ? extends Comparable> entityIndex) { return new AttributeOrder<>(entityIndex.getAttribute(), true); }
/** * Creates a {@link Between} query which asserts that an attribute is between a lower and an upper bound, * inclusive. * * @param entityIndex The index to which the query refers * @param lowerValue The lower bound to be asserted by the query * @param upperValue The upper bound to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return A {@link GreaterThan} query */ static <O extends Entity, A extends Comparable<A>> Between<EntityHandle<O>, A> between(EntityIndex<O, A> entityIndex, A lowerValue, A upperValue) { return new Between<>(entityIndex.getAttribute(), lowerValue, true, upperValue, true); }
/** * Creates a {@link StringMatchesRegex} query which asserts that an attribute's value matches a regular expression. * <p> * To accelerate {@code matchesRegex(...)} queries, add a Standing Query Index on {@code matchesRegex(...)}. * * @param entityIndex The index to which the query refers * @param regexPattern The regular expression pattern to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link StringStartsWith} query */ static <O extends Entity, A extends CharSequence> StringMatchesRegex<EntityHandle<O>, A> matchesRegex(EntityIndex<O, A> entityIndex, Pattern regexPattern) { return new StringMatchesRegex<>(entityIndex.getAttribute(), regexPattern); }
/** * Creates a {@link StringIsContainedIn} query which asserts that an attribute is contained in a certain string * fragment. * * @param entityIndex The index to which the query refers * @param attributeValue The value to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link StringStartsWith} query */ @Deprecated static <O extends Entity, A extends CharSequence> StringIsContainedIn<EntityHandle<O>, A> isContainedIn(EntityIndex<O, A> entityIndex, A attributeValue) { return new StringIsContainedIn<>(entityIndex.getAttribute(), attributeValue); }
/** * Creates a {@link LessThan} query which asserts that an attribute is less than or equal to an upper bound * (i.e. less than, inclusive). * * @param entityIndex The index to which the query refers * @param attributeValue The upper bound to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return A {@link LessThan} query */ static <O extends Entity, A extends Comparable<A>> LessThan<EntityHandle<O>, A> lessThanOrEqualTo(EntityIndex<O, A> entityIndex, A attributeValue) { return new LessThan<>(entityIndex.getAttribute(), attributeValue, true); }
/** * Creates a {@link StringMatchesRegex} query which asserts that an attribute's value matches a regular expression. * <p> * To accelerate {@code matchesRegex(...)} queries, add a Standing Query Index on {@code matchesRegex(...)}. * * @param entityIndex The index to which the query refers * @param regex The regular expression to be asserted by the query (this will be compiled via {@link Pattern#compile(String)}) * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return An {@link StringStartsWith} query */ static <O extends Entity, A extends CharSequence> StringMatchesRegex<EntityHandle<O>, A> matchesRegex(EntityIndex<O, A> entityIndex, String regex) { return new StringMatchesRegex<>(entityIndex.getAttribute(), Pattern.compile(regex)); }
/** * Creates a {@link LessThan} query which asserts that an attribute is less than (but not equal to) an upper * bound (i.e. less than, exclusive). * * @param entityIndex The index to which the query refers * @param attributeValue The upper bound to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return A {@link LessThan} query */ static <O extends Entity, A extends Comparable<A>> LessThan<EntityHandle<O>, A> lessThan(EntityIndex<O, A> entityIndex, A attributeValue) { return new LessThan<>(entityIndex.getAttribute(), attributeValue, false); }
/** * Creates a {@link GreaterThan} query which asserts that an attribute is greater than or equal to a lower * bound (i.e. greater than, inclusive). * * @param entityIndex The index to which the query refers * @param attributeValue The lower bound to be asserted by the query * @param <A> The type of the attribute * @param <O> The type of the object containing the attribute * @return A {@link GreaterThan} query */ static <O extends Entity, A extends Comparable<A>> GreaterThan<EntityHandle<O>, A> greaterThanOrEqualTo(EntityIndex<O, A> entityIndex, A attributeValue) { return new GreaterThan<>(entityIndex.getAttribute(), attributeValue, true); }