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 forKey
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Key.BuilderaddPartitionValue(Object value)Adds a partition key value to this key builder for composite partition keys.Key.BuilderaddSortValue(Object value)Adds a sort key value to this key builder for composite sort keys.Keybuild()Construct aKeyfrom this builder.Key.BuilderpartitionValue(Number partitionValue)Numeric value to be used for the single partition key.Key.BuilderpartitionValue(String partitionValue)String value to be used for the single partition key.Key.BuilderpartitionValue(SdkBytes partitionValue)Binary value to be used for the single partition key.Key.BuilderpartitionValue(AttributeValue partitionValue)Value to be used for the single partition keyKey.BuilderpartitionValues(List<AttributeValue> partitionValues)Values to be used for composite partition keysKey.BuildersortValue(Number sortValue)Numeric value to be used for the single sort key.Key.BuildersortValue(String sortValue)String value to be used for the single sort key.Key.BuildersortValue(SdkBytes sortValue)Binary value to be used for the single sort key.Key.BuildersortValue(AttributeValue sortValue)Value to be used for the single sort keyKey.BuildersortValues(List<AttributeValue> sortValues)Values to be used for composite sort keys
-
-
-
Method Detail
-
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
AttributeValueusing 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
AttributeValueusing 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 keyUse
partitionValues(List)oraddPartitionValue(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)oraddPartitionValue(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)oraddPartitionValue(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)oraddPartitionValue(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 keyUse
sortValues(List)oraddSortValue(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)oraddSortValue(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)oraddSortValue(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)oraddSortValue(Object)for composite key support- Parameters:
sortValue- the bytes to be used for the binary key value.
-
-