Package org.forgerock.am.cts.api.filter
Class TokenFilterBuilder
java.lang.Object
org.forgerock.am.cts.api.filter.TokenFilterBuilder
Allows the assembly of
TokenFilter instances for use with the CTSPersistentStore
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 ClassesModifier and TypeClassDescriptionclass -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionand()Creates an AND query where the results must match all provided filters.build()or()Creates an OR query where the results will match any of the provided filters.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.withAttribute(CoreTokenField field, Object value) Filters the result CTS Tokens to only include those that have the matching attribute.withQuery(QueryFilter<CoreTokenField> query) Rather than building up the query using these builder methods, callers can define the entire query themselves.withSizeLimit(int sizeLimit) Sets the size limit for the query request.withTimeLimit(Duration timeLimit) Sets the time limit for the query request.
-
Constructor Details
-
TokenFilterBuilder
public TokenFilterBuilder()
-
-
Method Details
-
and
Creates an AND query where the results must match all provided filters.- Returns:
- Non null FilterAttributeBuilder.
-
or
Creates an OR query where the results will match any of the provided filters.- Returns:
- Non null FilterAttributeBuilder.
-
withAttribute
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- TheCoreTokenFieldto filter against.value- The value for the field.- Returns:
- Moves the builder into AND mode, with the filter assigned.
- See Also:
-
withQuery
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 theQueryFilterapi.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
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
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
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
- Returns:
- The assembled TokenFilter.
-