Class Key.Builder

java.lang.Object
software.amazon.awssdk.enhanced.dynamodb.Key.Builder
Enclosing class:
Key

@NotThreadSafe public static final class Key.Builder extends Object
Builder for Key
  • Method Details

    • partitionValues

      public Key.Builder partitionValues(List<AttributeValue> partitionValues)
      Values to be used for composite partition keys
      Parameters:
      partitionValues - list of partition key values (max 4)
    • sortValues

      public Key.Builder sortValues(List<AttributeValue> sortValues)
      Values to be used for composite sort keys
      Parameters:
      sortValues - list of sort key values (max 4)
    • addPartitionValue

      public Key.Builder addPartitionValue(Object value)
      Adds a partition key value to this key builder for composite partition keys.

      The value will be automatically converted to a DynamoDB AttributeValue using the default attribute converter. Supported types include primitives, strings, numbers, binary data, and other standard Java types that can be mapped to DynamoDB attribute values.

      For composite partition keys, values are added in order (0, 1, 2, 3) and must match the order defined in the table schema.

      Parameters:
      value - the partition key value to add. Must not be null.
      Returns:
      this builder instance for method chaining
      Throws:
      IllegalArgumentException - if value is null or the value type cannot be converted to an AttributeValue
    • addSortValue

      public Key.Builder addSortValue(Object value)
      Adds a sort key value to this key builder for composite sort keys.

      The value will be automatically converted to a DynamoDB AttributeValue using the default attribute converter. Supported types include primitives, strings, numbers, binary data, and other standard Java types that can be mapped to DynamoDB attribute values.

      For composite sort keys, values are added in order (0, 1, 2, 3) and must match the order defined in the table schema.

      Parameters:
      value - the sort key value to add. Must not be null.
      Returns:
      this builder instance for method chaining
      Throws:
      IllegalArgumentException - if value is null or the value type cannot be converted to an AttributeValue
    • partitionValue

      public Key.Builder partitionValue(AttributeValue partitionValue)
      Value to be used for the single partition key

      Use partitionValues(List) or addPartitionValue(Object) for composite key support

      Parameters:
      partitionValue - partition key value
    • partitionValue

      public Key.Builder partitionValue(String partitionValue)
      String value to be used for the single partition key. The string will be converted into an AttributeValue of type S.

      Use partitionValues(List) or addPartitionValue(Object) for composite key support

      Parameters:
      partitionValue - partition key value
    • partitionValue

      public Key.Builder partitionValue(Number partitionValue)
      Numeric value to be used for the single partition key. The number will be converted into an AttributeValue of type N.

      Use partitionValues(List) or addPartitionValue(Object) for composite key support

      Parameters:
      partitionValue - partition key value
    • partitionValue

      public Key.Builder partitionValue(SdkBytes partitionValue)
      Binary value to be used for the single partition key. The input will be converted into an AttributeValue of type B.

      Use partitionValues(List) or addPartitionValue(Object) for composite key support

      Parameters:
      partitionValue - the bytes to be used for the binary key value.
    • sortValue

      public Key.Builder sortValue(AttributeValue sortValue)
      Value to be used for the single sort key

      Use sortValues(List) or addSortValue(Object) for composite key support

      Parameters:
      sortValue - sort key value
    • sortValue

      public Key.Builder sortValue(String sortValue)
      String value to be used for the single sort key. The string will be converted into an AttributeValue of type S.

      Use sortValues(List) or addSortValue(Object) for composite key support

      Parameters:
      sortValue - sort key value
    • sortValue

      public Key.Builder sortValue(Number sortValue)
      Numeric value to be used for the single sort key. The number will be converted into an AttributeValue of type N.

      Use sortValues(List) or addSortValue(Object) for composite key support

      Parameters:
      sortValue - sort key value
    • sortValue

      public Key.Builder sortValue(SdkBytes sortValue)
      Binary value to be used for the single sort key. The input will be converted into an AttributeValue of type B.

      Use sortValues(List) or addSortValue(Object) for composite key support

      Parameters:
      sortValue - the bytes to be used for the binary key value.
    • build

      public Key build()
      Construct a Key from this builder.