Package org.forgerock.util.query
Class QueryFilter<F>
java.lang.Object
org.forgerock.util.query.QueryFilter<F>
- Type Parameters:
F- The type of the field specification.
A filter which can be used to select resources, which is compatible with the CREST query filters.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedQueryFilter(org.forgerock.util.query.QueryFilter.Impl<F> pimpl) Construct a QueryFilter from a base filter implementation.protectedQueryFilter(org.forgerock.util.query.QueryFilter.Impl<F> pimpl, QueryFilterVisitor<StringBuilder, StringBuilder, F> toStringVisitor) Construct a QueryFilter from a base filter implementation and a custom toString implementation. -
Method Summary
Modifier and TypeMethodDescription<R,P> R accept(QueryFilterVisitor<R, P, F> v, P p) Applies aQueryFilterVisitorto thisQueryFilter.static <FF> QueryFilter<FF>Returns a filter which does not match any resources.static <FF> QueryFilter<FF>Returns a filter which matches all resources.static <FF> QueryFilter<FF>and(Collection<QueryFilter<FF>> subFilters) Creates a newandfilter using the provided list of sub-filters.static <FF> QueryFilter<FF>and(QueryFilter<FF>... subFilters) Creates a newandfilter using the provided list of sub-filters.static <FF> QueryFilter<FF>comparisonFilter(FF field, String operator, Object valueAssertion) Creates a new generic comparison filter using the provided field name, operator, and value assertion.static <FF> QueryFilter<FF>complex(FF field, QueryFilter<FF> subFilter) Creates a newcomplexfilter using the provided field name and sub-filter expression.static <FF> QueryFilter<FF>Creates a newcontainsfilter using the provided field name and value assertion.booleanstatic <FF> QueryFilter<FF>Creates a newequalityfilter using the provided field name and value assertion.static <FF> QueryFilter<FF>extendedMatch(FF field, String operator, Object valueAssertion) Creates a newextended matchfilter using the provided field name, operator and value assertion.static <FF> QueryFilter<FF>greaterThan(FF field, Object valueAssertion) Creates a newgreater thanfilter using the provided field name and value assertion.static <FF> QueryFilter<FF>greaterThanOrEqualTo(FF field, Object valueAssertion) Creates a newgreater than or equal tofilter using the provided field name and value assertion.inthashCode()static <FF> QueryFilter<FF>Creates a newless thanfilter using the provided field name and value assertion.static <FF> QueryFilter<FF>lessThanOrEqualTo(FF field, Object valueAssertion) Creates a newless than or equal tofilter using the provided field name and value assertion.static <FF> QueryFilter<FF>not(QueryFilter<FF> subFilter) Creates a newnotfilter using the provided sub-filter.static <FF> QueryFilter<FF>or(Collection<QueryFilter<FF>> subFilters) Creates a neworfilter using the provided list of sub-filters.static <FF> QueryFilter<FF>or(QueryFilter<FF>... subFilters) Creates a neworfilter using the provided list of sub-filters.static <FF> QueryFilter<FF>present(FF field) Creates a newpresencefilter using the provided field name.static <FF> QueryFilter<FF>startsWith(FF field, Object valueAssertion) Creates a newstarts withfilter using the provided field name and value assertion.toString()Returns the string representation of this query filter.
-
Field Details
-
pimpl
the filter implementation.
-
-
Constructor Details
-
QueryFilter
Construct a QueryFilter from a base filter implementation.- Parameters:
pimpl- the filter implementation.
-
QueryFilter
protected QueryFilter(org.forgerock.util.query.QueryFilter.Impl<F> pimpl, QueryFilterVisitor<StringBuilder, StringBuilder, F> toStringVisitor) Construct a QueryFilter from a base filter implementation and a custom toString implementation.- Parameters:
pimpl- the filter implemntation.toStringVisitor- the visitor to provide a toString implementation.
-
-
Method Details
-
alwaysFalse
Returns a filter which does not match any resources.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Returns:
- A filter which does not match any resources.
-
alwaysTrue
Returns a filter which matches all resources.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Returns:
- A filter which matches all resources.
-
and
Creates a newandfilter using the provided list of sub-filters.Creating a new
andfilter with anullor empty list of sub-filters is equivalent to callingalwaysTrue().- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
subFilters- The list of sub-filters, may be empty ornull.- Returns:
- The newly created
andfilter.
-
and
Creates a newandfilter using the provided list of sub-filters.Creating a new
andfilter with anullor empty list of sub-filters is equivalent to callingalwaysTrue().- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
subFilters- The list of sub-filters, may be empty ornull.- Returns:
- The newly created
andfilter.
-
comparisonFilter
public static <FF> QueryFilter<FF> comparisonFilter(FF field, String operator, Object valueAssertion) Creates a new generic comparison filter using the provided field name, operator, and value assertion. When the provided operator name represents a core operator, e.g. "eq", then this method is equivalent to calling the equivalent constructor, e.g.equalTo(Object, Object). Otherwise, when the operator name does not correspond to a core operator, an extended comparison filter will be returned.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
field- The name of field within the JSON resource to be compared.operator- The operator to use for the comparison, which must be one of the core operator names, or a string matching the regular expression[a-zA-Z_0-9.]+.valueAssertion- The assertion value.- Returns:
- The newly created generic comparison filter.
- Throws:
IllegalArgumentException- Ifoperatoris not a valid operator name.
-
contains
Creates a newcontainsfilter using the provided field name and value assertion. This method is used to check that the string representation of the field contains the provided substring. When operating on a collection of values the operation should be evaluated on each element in the collection, passing if any of the element's string representations contain the provided substring.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
field- The name of field to be compared.valueAssertion- The assertion value.- Returns:
- The newly created
containsfilter.
-
equalTo
Creates a newequalityfilter using the provided field name and value assertion. This would represent either equality for single values, or contains and equal value for a collection of values.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
field- The name of field to be compared.valueAssertion- The assertion value.- Returns:
- The newly created
equalityfilter.
-
greaterThan
Creates a newgreater thanfilter using the provided field name and value assertion. This method is used to check that the value of the field is greater than the provided value. When operating on a collection of values the operation should be evaluated on each element in the collection, passing if any of the element's values are greater than the provided value.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
field- The name of field to be compared.valueAssertion- The assertion value.- Returns:
- The newly created
greater thanfilter.
-
greaterThanOrEqualTo
Creates a newgreater than or equal tofilter using the provided field name and value assertion. This method is used to check that the value of the field is greater than or equal to the provided value. When operating on a collection of values the operation should be evaluated on each element in the collection, passing if any of the element's values are greater than or equal to the provided value.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
field- The name of field to be compared.valueAssertion- The assertion value.- Returns:
- The newly created
greater than or equal tofilter.
-
lessThan
Creates a newless thanfilter using the provided field name and value assertion. This method is used to check that the value of the field is less than the provided value. When operating on a collection of values the operation should be evaluated on each element in the collection, passing if any of the element's values are less than the provided value.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
field- The name of field to be compared.valueAssertion- The assertion value.- Returns:
- The newly created
less thanfilter.
-
extendedMatch
Creates a newextended matchfilter using the provided field name, operator and value assertion.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
field- The name of field to be compared.operator- The operator.valueAssertion- The assertion value.- Returns:
- The newly created
less than or equal tofilter.
-
lessThanOrEqualTo
Creates a newless than or equal tofilter using the provided field name and value assertion. This method is used to check that the value of the field is less than or equal to the provided value. When operating on a collection of values the operation should be evaluated on each element in the collection, passing if any of the element's values are less than or equal to the provided value.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
field- The name of field to be compared.valueAssertion- The assertion value.- Returns:
- The newly created
less than or equal tofilter.
-
not
Creates a newnotfilter using the provided sub-filter.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
subFilter- The sub-filter.- Returns:
- The newly created
notfilter.
-
or
Creates a neworfilter using the provided list of sub-filters.Creating a new
orfilter with anullor empty list of sub-filters is equivalent to callingalwaysFalse().- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
subFilters- The list of sub-filters, may be empty ornull.- Returns:
- The newly created
orfilter.
-
or
Creates a neworfilter using the provided list of sub-filters.Creating a new
orfilter with anullor empty list of sub-filters is equivalent to callingalwaysFalse().- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
subFilters- The list of sub-filters, may be empty ornull.- Returns:
- The newly created
orfilter.
-
present
Creates a newpresencefilter using the provided field name.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
field- The name of field which must be present.- Returns:
- The newly created
presencefilter.
-
startsWith
Creates a newstarts withfilter using the provided field name and value assertion. This method is used to check that the string representation of the field starts with the provided substring. When operating on a collection of values the operation should be evaluated on each element in the collection, passing if any of the element's string representations starts with the provided substring.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
field- The name of field to be compared.valueAssertion- The assertion value.- Returns:
- The newly created
starts withfilter.
-
complex
Creates a newcomplexfilter using the provided field name and sub-filter expression. This method is used to check that child attributes beneath the parent attributefieldmeet the criteria set forth by the sub-expression. When operating on a collection of values the operation should be evaluated on each element in the collection, passing if an element's sub-attributes match the given sub-filter.- Type Parameters:
FF- The type of the field specification. Named to be distinct from the type of the parent class.- Parameters:
field- The name of field to be compared.subFilter- The sub-expression applied to child attributes offield.- Returns:
- The newly created
complexfilter.
-
accept
Applies aQueryFilterVisitorto thisQueryFilter.- Type Parameters:
R- The return type of the visitor's methods.P- The type of the additional parameters to the visitor's methods.- Parameters:
v- The filter visitor.p- Optional additional visitor parameter.- Returns:
- A result as specified by the visitor.
-
equals
-
hashCode
public int hashCode() -
toString
Returns the string representation of this query filter. The string representation is defined to be similar to that of SCIM's, with the following differences:- field references are JSON pointers
- support for boolean literal expressions, e.g.
(true) - support for the logical not operator, e.g.
(! /role eq "user")
-