Interface EnhancedDocument.Builder
- All Known Implementing Classes:
DefaultEnhancedDocument.DefaultBuilder
- Enclosing interface:
EnhancedDocument
-
Method Summary
Modifier and TypeMethodDescriptionaddAttributeConverterProvider
(AttributeConverterProvider attributeConverterProvider) Appends collection of attributeConverterProvider to the document builder.attributeConverterProviders
(List<AttributeConverterProvider> attributeConverterProviders) Sets the collection of attributeConverterProviders to the document builder.attributeConverterProviders
(AttributeConverterProvider... attributeConverterProvider) Sets collection of attributeConverterProviders to the document builder.attributeValueMap
(Map<String, AttributeValue> attributeValueMap) Sets the attributes of the document builder to those specified in the provided from a AttributeValue Map, and completely replaces any previously set attributes.build()
Builds an instance ofEnhancedDocument
.Sets the attributes of the document builder to those specified in the provided JSON string, and completely replaces any previously set attributes.Appends an attribute namedattributeName
with a value of Class type T.put
(String attributeName, T value, EnhancedType<T> type) Appends an attribute namedattributeName
with a value of typeEnhancedType
T.putBoolean
(String attributeName, boolean value) Use this method when you need to add a boolean value to a document.Appends an attribute of name attributeName with specifiedSdkBytes
value to the document builder.putBytesSet
(String attributeName, Set<SdkBytes> values) Appends an attribute of name attributeName with specified Set ofSdkBytes
values to the document builder.Appends an attribute to the document builder with the specified name and value of a JSON document in string format.putList
(String attributeName, List<T> value, EnhancedType<T> type) Appends an attribute with the specified name and a list ofEnhancedType
T type elements to the document builder.<K,
V> EnhancedDocument.Builder putMap
(String attributeName, Map<K, V> value, EnhancedType<K> keyType, EnhancedType<V> valueType) Appends an attribute with the specified name and a Map containing keys and values ofEnhancedType
K and V types, respectively, to the document builder.Appends an attribute of name attributeName with a null value.Appends an attribute of name attributeName with specifiedNumber
value to the document builder.putNumberSet
(String attributeName, Set<Number> values) Appends an attribute of name attributeName with specified Set ofNumber
values to the document builder.Appends an attribute of name attributeName with specifiedString
value to the document builder.putStringSet
(String attributeName, Set<String> values) Appends an attribute to the document builder with a Set of Strings as its value.Removes a previously appended attribute.
-
Method Details
-
putString
Appends an attribute of name attributeName with specifiedString
value to the document builder. Use this method when you need to add a string value to a document. If you need to add an attribute with a value of a different type, such as a number or a map, use the appropriate put method instead- Parameters:
attributeName
- the name of the attribute to be added to the document.value
- The string value that needs to be set.- Returns:
- Builder instance to construct a
EnhancedDocument
-
putNumber
Appends an attribute of name attributeName with specifiedNumber
value to the document builder. Use this method when you need to add a number value to a document. If you need to add an attribute with a value of a different type, such as a string or a map, use the appropriate put method instead- Parameters:
attributeName
- the name of the attribute to be added to the document.value
- The number value that needs to be set.- Returns:
- Builder instance to construct a
EnhancedDocument
-
putBytes
Appends an attribute of name attributeName with specifiedSdkBytes
value to the document builder. Use this method when you need to add a binary value to a document. If you need to add an attribute with a value of a different type, such as a string or a map, use the appropriate put method instead- Parameters:
attributeName
- the name of the attribute to be added to the document.value
- The byte array value that needs to be set.- Returns:
- Builder instance to construct a
EnhancedDocument
-
putBoolean
Use this method when you need to add a boolean value to a document. If you need to add an attribute with a value of a different type, such as a string or a map, use the appropriate put method instead.- Parameters:
attributeName
- the name of the attribute to be added to the document.value
- The boolean value that needs to be set.- Returns:
- Builder instance to construct a
EnhancedDocument
-
putNull
Appends an attribute of name attributeName with a null value. Use this method is the attribute needs to explicitly set to null in Dynamo DB table.- Parameters:
attributeName
- the name of the attribute to be added to the document.- Returns:
- Builder instance to construct a
EnhancedDocument
-
putStringSet
Appends an attribute to the document builder with a Set of Strings as its value. This method is intended for use in DynamoDB where attribute values are stored as Sets of Strings.- Parameters:
attributeName
- the name of the attribute to be added to the document.values
- Set of String values that needs to be set.- Returns:
- Builder instance to construct a
EnhancedDocument
-
putNumberSet
Appends an attribute of name attributeName with specified Set ofNumber
values to the document builder.- Parameters:
attributeName
- the name of the attribute to be added to the document.values
- Set of Number values that needs to be set.- Returns:
- Builder instance to construct a
EnhancedDocument
-
putBytesSet
Appends an attribute of name attributeName with specified Set ofSdkBytes
values to the document builder.- Parameters:
attributeName
- the name of the attribute to be added to the document.values
- Set of SdkBytes values that needs to be set.- Returns:
- Builder instance to construct a
EnhancedDocument
-
putList
Appends an attribute with the specified name and a list ofEnhancedType
T type elements to the document builder. UseEnhancedType.of(Class)
to specify the class type of the list elements.For example, to insert a list of String type:
EnhancedDocument.builder().putList(stringList, EnhancedType.of(String.class))
Example for inserting a List of Custom type .
EnhancedDocument.builder().putList(stringList, EnhancedType.of(CustomClass.class));
- Parameters:
attributeName
- the name of the attribute to be added to the document.value
- The list of values that needs to be set.- Returns:
- Builder instance to construct a
EnhancedDocument
-
put
Appends an attribute namedattributeName
with a value of typeEnhancedType
T. Use this method to insert attribute values of custom types that have attribute converters defined in a converter provider. Example:EnhancedDocument.builder().put("customKey", customValue, EnhancedType.of(CustomClass.class));
putString(String, String)
orputNumber(String, Number)
for inserting simple value types of attributes. UseputList(String, List, EnhancedType)
orputMap(String, Map, EnhancedType, EnhancedType)
for inserting collections of attribute values. Note that the attribute converter provider added to the DocumentBuilder must provide the converter for the class T that is to be inserted.- Type Parameters:
T
- the type of the value to set.- Parameters:
attributeName
- the name of the attribute to be added to the document.value
- the value to set.type
- the Enhanced type of the value to set.- Returns:
- a builder instance to construct a
EnhancedDocument
.
-
put
Appends an attribute namedattributeName
with a value of Class type T. Use this method to insert attribute values of custom types that have attribute converters defined in a converter provider. Example:EnhancedDocument.builder().put("customKey", customValue, CustomClass.class);
putString(String, String)
orputNumber(String, Number)
for inserting simple value types of attributes. UseputList(String, List, EnhancedType)
orputMap(String, Map, EnhancedType, EnhancedType)
for inserting collections of attribute values. Note that the attribute converter provider added to the DocumentBuilder must provide the converter for the class T that is to be inserted.- Type Parameters:
T
- the type of the value to set.- Parameters:
attributeName
- the name of the attribute to be added to the document.value
- the value to set.type
- the type of the value to set.- Returns:
- a builder instance to construct a
EnhancedDocument
.
-
putMap
<K,V> EnhancedDocument.Builder putMap(String attributeName, Map<K, V> value, EnhancedType<K> keyType, EnhancedType<V> valueType) Appends an attribute with the specified name and a Map containing keys and values ofEnhancedType
K and V types, respectively, to the document builder. UseEnhancedType.of(Class)
to specify the class type of the keys and values.For example, to insert a map with String keys and Long values:
EnhancedDocument.builder().putMap("stringMap", mapWithStringKeyNumberValue, EnhancedType.of(String.class), EnhancedType.of(String.class), EnhancedType.of(Long.class))
For example, to insert a map of String Key and Custom Values:
EnhancedDocument.builder().putMap("customMap", mapWithStringKeyCustomValue, EnhancedType.of(String.class), EnhancedType.of(String.class), EnhancedType.of(Custom.class))
- Parameters:
attributeName
- the name of the attribute to be added to the documentvalue
- The Map of values that needs to be set.keyType
- Enhanced type of Key classvalueType
- Enhanced type of Value class.- Returns:
- Builder instance to construct a
EnhancedDocument
-
putJson
Appends an attribute to the document builder with the specified name and value of a JSON document in string format.- Parameters:
attributeName
- the name of the attribute to be added to the document.json
- JSON document in the form of a string.- Returns:
- Builder instance to construct a
EnhancedDocument
-
remove
Removes a previously appended attribute. This can be used where a previously added attribute to the Builder is no longer needed.- Parameters:
attributeName
- The attribute that needs to be removed.- Returns:
- Builder instance to construct a
EnhancedDocument
-
addAttributeConverterProvider
EnhancedDocument.Builder addAttributeConverterProvider(AttributeConverterProvider attributeConverterProvider) Appends collection of attributeConverterProvider to the document builder. These AttributeConverterProvider will be used to convert any given key to custom type T. The first matching converter from the given provider will be selected based on the order in which they are added.- Parameters:
attributeConverterProvider
- determining theAttributeConverter
to use for converting a value.- Returns:
- Builder instance to construct a
EnhancedDocument
-
attributeConverterProviders
EnhancedDocument.Builder attributeConverterProviders(List<AttributeConverterProvider> attributeConverterProviders) Sets the collection of attributeConverterProviders to the document builder. These AttributeConverterProvider will be used to convert value of any given key to custom type T. The first matching converter from the given provider will be selected based on the order in which they are added.- Parameters:
attributeConverterProviders
- determining theAttributeConverter
to use for converting a value.- Returns:
- Builder instance to construct a
EnhancedDocument
-
attributeConverterProviders
EnhancedDocument.Builder attributeConverterProviders(AttributeConverterProvider... attributeConverterProvider) Sets collection of attributeConverterProviders to the document builder. These AttributeConverterProvider will be used to convert any given key to custom type T. The first matching converter from the given provider will be selected based on the order in which they are added.- Parameters:
attributeConverterProvider
- determining theAttributeConverter
to use for converting a value.- Returns:
- Builder instance to construct a
EnhancedDocument
-
json
Sets the attributes of the document builder to those specified in the provided JSON string, and completely replaces any previously set attributes.- Parameters:
json
- a JSON document represented as a string- Returns:
- a builder instance to construct a
EnhancedDocument
- Throws:
NullPointerException
- if the json parameter is null
-
attributeValueMap
Sets the attributes of the document builder to those specified in the provided from a AttributeValue Map, and completely replaces any previously set attributes.- Parameters:
attributeValueMap
- - Map with Attributes as String keys and AttributeValue as Value.- Returns:
- Builder instance to construct a
EnhancedDocument
-
build
EnhancedDocument build()Builds an instance ofEnhancedDocument
.- Returns:
- instance of
EnhancedDocument
implementation.
-