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
ConstructorsModifierConstructorDescriptionprotected
QueryFilter
(org.forgerock.util.query.QueryFilter.Impl<F> pimpl) Construct a QueryFilter from a base filter implementation.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. -
Method Summary
Modifier and TypeMethodDescription<R,
P> R accept
(QueryFilterVisitor<R, P, F> v, P p) Applies aQueryFilterVisitor
to 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 newand
filter using the provided list of sub-filters.static <FF> QueryFilter<FF>
and
(QueryFilter<FF>... subFilters) Creates a newand
filter 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 newcomplex
filter using the provided field name and sub-filter expression.static <FF> QueryFilter<FF>
Creates a newcontains
filter using the provided field name and value assertion.boolean
static <FF> QueryFilter<FF>
Creates a newequality
filter using the provided field name and value assertion.static <FF> QueryFilter<FF>
extendedMatch
(FF field, String operator, Object valueAssertion) Creates a newextended match
filter using the provided field name, operator and value assertion.static <FF> QueryFilter<FF>
greaterThan
(FF field, Object valueAssertion) Creates a newgreater than
filter using the provided field name and value assertion.static <FF> QueryFilter<FF>
greaterThanOrEqualTo
(FF field, Object valueAssertion) Creates a newgreater than or equal to
filter using the provided field name and value assertion.int
hashCode()
static <FF> QueryFilter<FF>
Creates a newless than
filter using the provided field name and value assertion.static <FF> QueryFilter<FF>
lessThanOrEqualTo
(FF field, Object valueAssertion) Creates a newless than or equal to
filter using the provided field name and value assertion.static <FF> QueryFilter<FF>
not
(QueryFilter<FF> subFilter) Creates a newnot
filter using the provided sub-filter.static <FF> QueryFilter<FF>
or
(Collection<QueryFilter<FF>> subFilters) Creates a newor
filter using the provided list of sub-filters.static <FF> QueryFilter<FF>
or
(QueryFilter<FF>... subFilters) Creates a newor
filter using the provided list of sub-filters.static <FF> QueryFilter<FF>
present
(FF field) Creates a newpresence
filter using the provided field name.static <FF> QueryFilter<FF>
startsWith
(FF field, Object valueAssertion) Creates a newstarts with
filter 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 newand
filter using the provided list of sub-filters.Creating a new
and
filter with anull
or 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
and
filter.
-
and
Creates a newand
filter using the provided list of sub-filters.Creating a new
and
filter with anull
or 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
and
filter.
-
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
- Ifoperator
is not a valid operator name.
-
contains
Creates a newcontains
filter 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
contains
filter.
-
equalTo
Creates a newequality
filter 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
equality
filter.
-
greaterThan
Creates a newgreater than
filter 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 than
filter.
-
greaterThanOrEqualTo
Creates a newgreater than or equal to
filter 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 to
filter.
-
lessThan
Creates a newless than
filter 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 than
filter.
-
extendedMatch
Creates a newextended match
filter 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 to
filter.
-
lessThanOrEqualTo
Creates a newless than or equal to
filter 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 to
filter.
-
not
Creates a newnot
filter 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
not
filter.
-
or
Creates a newor
filter using the provided list of sub-filters.Creating a new
or
filter with anull
or 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
or
filter.
-
or
Creates a newor
filter using the provided list of sub-filters.Creating a new
or
filter with anull
or 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
or
filter.
-
present
Creates a newpresence
filter 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
presence
filter.
-
startsWith
Creates a newstarts with
filter 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 with
filter.
-
complex
Creates a newcomplex
filter using the provided field name and sub-filter expression. This method is used to check that child attributes beneath the parent attributefield
meet 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
complex
filter.
-
accept
Applies aQueryFilterVisitor
to 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")
-