Class TokenFilterBuilder

java.lang.Object
org.forgerock.am.cts.api.filter.TokenFilterBuilder

public class TokenFilterBuilder extends Object
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.

  • 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

      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 if and() had been called.
      Parameters:
      field - The CoreTokenField to filter against.
      value - The value for the field.
      Returns:
      Moves the builder into AND mode, with the filter assigned.
      See Also:
    • 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 the QueryFilter api.

      Note: Using this option will disable other options in this Builder. E.g. cannot be followed by or(), and(), or withAttribute(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 standard CoreTokenField.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.