Package org.forgerock.am.cts.api.filter
Class TokenFilterBuilder
- java.lang.Object
-
- org.forgerock.am.cts.api.filter.TokenFilterBuilder
-
public class TokenFilterBuilder extends Object
Allows the assembly ofTokenFilter
instances for use with theCTSPersistentStore
and other uses of the generic data layer.The role of a TokenFilter is to restrict the results of a CTS query to both reduce load on the CTS and make the return results more specific to the callers query.
Each TokenFilter can include
CoreTokenField
attribute filters which ensure that only CTS tokens that have the matching attribute are returned.In addition the TokenFilter can define the return attributes from matched CTS Tokens. Rather than returning complete CTS tokens, when a return attribute is defined the CTS Tokens will only contain the defined subset of
CoreTokenField
attributes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
TokenFilterBuilder.FilterAttributeBuilder
-
Constructor Summary
Constructors Constructor Description TokenFilterBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TokenFilterBuilder.FilterAttributeBuilder
and()
Creates an AND query where the results must match all provided filters.TokenFilter
build()
TokenFilterBuilder.FilterAttributeBuilder
or()
Creates an OR query where the results will match any of the provided filters.TokenFilterBuilder
returnAttribute(CoreTokenField field)
If you only require the returned CTS Tokens to contains a subset of the standardCoreTokenField.values()
then this method allows the caller to specify the fields they would like in the returned CTS Tokens.TokenFilterBuilder.FilterAttributeBuilder
withAttribute(CoreTokenField field, Object value)
Filters the result CTS Tokens to only include those that have the matching attribute.TokenFilterBuilder
withQuery(QueryFilter<CoreTokenField> query)
Rather than building up the query using these builder methods, callers can define the entire query themselves.TokenFilterBuilder
withSizeLimit(int sizeLimit)
Sets the size limit for the query request.TokenFilterBuilder
withTimeLimit(Duration timeLimit)
Sets the time limit for the query request.
-
-
-
Method Detail
-
and
public TokenFilterBuilder.FilterAttributeBuilder and()
Creates an AND query where the results must match all provided filters.- Returns:
- Non null FilterAttributeBuilder.
-
or
public TokenFilterBuilder.FilterAttributeBuilder or()
Creates an OR query where the results will match any of the provided filters.- Returns:
- Non null FilterAttributeBuilder.
-
withAttribute
public TokenFilterBuilder.FilterAttributeBuilder withAttribute(CoreTokenField field, Object value)
Filters the result CTS Tokens to only include those that have the matching attribute. Will also move this Builder into AND mode as ifand()
had been called.- Parameters:
field
- TheCoreTokenField
to filter against.value
- The value for the field.- Returns:
- Moves the builder into AND mode, with the filter assigned.
- See Also:
TokenFilterBuilder.FilterAttributeBuilder.withAttribute(CoreTokenField, Object)
-
withQuery
public TokenFilterBuilder withQuery(QueryFilter<CoreTokenField> query)
Rather than building up the query using these builder methods, callers can define the entire query themselves. This option allows for the full range of expressions provided in theQueryFilter
api.Note: Using this option will disable other options in this Builder. E.g. cannot be followed by
or()
,and()
, orwithAttribute(org.forgerock.am.cts.api.tokens.CoreTokenField, Object)
.- Parameters:
query
- The complex token query.- Returns:
- This builder.
-
withSizeLimit
public TokenFilterBuilder withSizeLimit(int sizeLimit)
Sets the size limit for the query request. Defaults to 0. The size limit will be enforced by the underlying backend technology.- Parameters:
sizeLimit
- The non-negative amount of entries that should be returned at most via the query.- Returns:
- This builder.
-
withTimeLimit
public TokenFilterBuilder withTimeLimit(Duration timeLimit)
Sets the time limit for the query request. Defaults to 0 seconds - no time limit. The time limit will be enforced by the underlying backend technology.- Parameters:
timeLimit
- The non-negative time duration under which the query must finish.- Returns:
- This builder.
-
returnAttribute
public TokenFilterBuilder returnAttribute(CoreTokenField field)
If you only require the returned CTS Tokens to contains a subset of the standardCoreTokenField.values()
then this method allows the caller to specify the fields they would like in the returned CTS Tokens.- Parameters:
field
- The required attribute to return from the query.- Returns:
- This query builder.
-
build
public TokenFilter build()
- Returns:
- The assembled TokenFilter.
-
-