Interface QueryConditional

All Known Implementing Classes:
BeginsWithConditional, BetweenConditional, EqualToConditional, SingleKeyItemConditional

@SdkPublicApi @ThreadSafe public interface QueryConditional
An interface for a literal conditional that can be used in an enhanced DynamoDB query. Contains convenient static methods that can be used to construct the most common conditional statements. Query conditionals are not linked to any specific table or schema and can be re-used in different contexts.

Example:

 
 QueryConditional sortValueGreaterThanFour = QueryConditional.sortGreaterThan(k -> k.partitionValue(10).sortValue(4));
 
 
  • Method Details

    • keyEqualTo

      static QueryConditional keyEqualTo(Key key)
      Creates a QueryConditional that matches when the key of an index is equal to a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and "=" operator will be applied on all of them. The sort keys are optional but if are provided, "=" operator will be applied only to the provided ones.

      Parameters:
      key - the literal key used to compare the value of the index against
    • keyEqualTo

      static QueryConditional keyEqualTo(Consumer<Key.Builder> keyConsumer)
      Creates a QueryConditional that matches when the key of an index is equal to a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and "=" operator will be applied on all of them. The sort keys are optional but if are provided, "=" operator will be applied only to the provided ones.

      Parameters:
      keyConsumer - 'builder consumer' for the literal key used to compare the value of the index against
    • sortGreaterThan

      static QueryConditional sortGreaterThan(Key key)
      Creates a QueryConditional that matches when the key of an index is greater than a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the ">" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      key - the literal key used to compare the value of the index against
    • sortGreaterThan

      static QueryConditional sortGreaterThan(Consumer<Key.Builder> keyConsumer)
      Creates a QueryConditional that matches when the key of an index is greater than a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the ">" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      keyConsumer - 'builder consumer' for the literal key used to compare the value of the index against
    • sortGreaterThanOrEqualTo

      static QueryConditional sortGreaterThanOrEqualTo(Key key)
      Creates a QueryConditional that matches when the key of an index is greater than or equal to a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the ">=" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      key - the literal key used to compare the value of the index against
    • sortGreaterThanOrEqualTo

      static QueryConditional sortGreaterThanOrEqualTo(Consumer<Key.Builder> keyConsumer)
      Creates a QueryConditional that matches when the key of an index is greater than or equal to a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the ">=" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      keyConsumer - 'builder consumer' for the literal key used to compare the value of the index against
    • sortLessThan

      static QueryConditional sortLessThan(Key key)
      Creates a QueryConditional that matches when the key of an index is less than a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the "invalid input: '<'" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      key - the literal key used to compare the value of the index against
    • sortLessThan

      static QueryConditional sortLessThan(Consumer<Key.Builder> keyConsumer)
      Creates a QueryConditional that matches when the key of an index is less than a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the "invalid input: '<'" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      keyConsumer - 'builder consumer' for the literal key used to compare the value of the index against
    • sortLessThanOrEqualTo

      static QueryConditional sortLessThanOrEqualTo(Key key)
      Creates a QueryConditional that matches when the key of an index is less than or equal to a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the "invalid input: '<'=" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      key - the literal key used to compare the value of the index against
    • sortLessThanOrEqualTo

      static QueryConditional sortLessThanOrEqualTo(Consumer<Key.Builder> keyConsumer)
      Creates a QueryConditional that matches when the key of an index is less than or equal to a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the "invalid input: '<'=" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      keyConsumer - 'builder consumer' for the literal key used to compare the value of the index against
    • sortBetween

      static QueryConditional sortBetween(Key keyFrom, Key keyTo)
      Creates a QueryConditional that matches when the key of an index is between two specific values. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the "between" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      keyFrom - the literal key used to compare the start of the range to compare the value of the index against
      keyTo - the literal key used to compare the end of the range to compare the value of the index against
    • sortBetween

      static QueryConditional sortBetween(Consumer<Key.Builder> keyFromConsumer, Consumer<Key.Builder> keyToConsumer)
      Creates a QueryConditional that matches when the key of an index is between two specific values. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the "between" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      keyFromConsumer - 'builder consumer' for the literal key used to compare the start of the range to compare the value of the index against
      keyToConsumer - 'builder consumer' for the literal key used to compare the end of the range to compare the value of the index against
    • sortBeginsWith

      static QueryConditional sortBeginsWith(Key key)
      Creates a QueryConditional that matches when the key of an index begins with a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the "begins_with" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      key - the literal key used to compare the start of the value of the index against
    • sortBeginsWith

      static QueryConditional sortBeginsWith(Consumer<Key.Builder> keyConsumer)
      Creates a QueryConditional that matches when the key of an index begins with a specific value. Supports both single keys and composite keys with up to 4 partition and 4 sort keys.

      In case of composite keys, all the partition keys must be provided and equality condition will be applied on all of them. For the sort keys, the "begins_with" operator will be applied only to the rightmost provided one, but all the preceding sort keys must also be provided and equality condition will be applied on them.

      Parameters:
      keyConsumer - 'builder consumer' the literal key used to compare the start of the value of the index against
    • expression

      Expression expression(TableSchema<?> tableSchema, String indexName)
      Generates a conditional Expression based on specific context that is supplied as arguments.
      Parameters:
      tableSchema - A TableSchema that this expression will be used with
      indexName - The specific index name of the index this expression will be used with
      Returns:
      A specific Expression that can be used as part of a query request