Class DefaultEnhancedDocument.DefaultBuilder
- java.lang.Object
-
- software.amazon.awssdk.enhanced.dynamodb.internal.document.DefaultEnhancedDocument.DefaultBuilder
-
- All Implemented Interfaces:
EnhancedDocument.Builder
- Enclosing class:
- DefaultEnhancedDocument
public static class DefaultEnhancedDocument.DefaultBuilder extends Object implements EnhancedDocument.Builder
-
-
Constructor Summary
Constructors Constructor Description DefaultBuilder(DefaultEnhancedDocument enhancedDocument)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EnhancedDocument.BuilderaddAttributeConverterProvider(AttributeConverterProvider attributeConverterProvider)Appends collection of attributeConverterProvider to the document builder.EnhancedDocument.BuilderattributeConverterProviders(List<AttributeConverterProvider> attributeConverterProviders)Sets the collection of attributeConverterProviders to the document builder.EnhancedDocument.BuilderattributeConverterProviders(AttributeConverterProvider... attributeConverterProviders)Sets collection of attributeConverterProviders to the document builder.EnhancedDocument.BuilderattributeValueMap(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.EnhancedDocumentbuild()Builds an instance ofEnhancedDocument.EnhancedDocument.Builderjson(String json)Sets the attributes of the document builder to those specified in the provided JSON string, and completely replaces any previously set attributes.<T> EnhancedDocument.Builderput(String attributeName, T value, Class<T> type)Appends an attribute namedattributeNamewith a value of Class type T.<T> EnhancedDocument.Builderput(String attributeName, T value, EnhancedType<T> type)Appends an attribute namedattributeNamewith a value of typeEnhancedTypeT.EnhancedDocument.BuilderputBoolean(String attributeName, boolean value)Use this method when you need to add a boolean value to a document.EnhancedDocument.BuilderputBytes(String attributeName, SdkBytes value)Appends an attribute of name attributeName with specifiedSdkBytesvalue to the document builder.EnhancedDocument.BuilderputBytesSet(String attributeName, Set<SdkBytes> values)Appends an attribute of name attributeName with specified Set ofSdkBytesvalues to the document builder.EnhancedDocument.BuilderputJson(String attributeName, String json)Appends an attribute to the document builder with the specified name and value of a JSON document in string format.<T> EnhancedDocument.BuilderputList(String attributeName, List<T> value, EnhancedType<T> type)Appends an attribute with the specified name and a list ofEnhancedTypeT type elements to the document builder.<K,V>
EnhancedDocument.BuilderputMap(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 ofEnhancedTypeK and V types, respectively, to the document builder.EnhancedDocument.BuilderputNull(String attributeName)Appends an attribute of name attributeName with a null value.EnhancedDocument.BuilderputNumber(String attributeName, Number value)Appends an attribute of name attributeName with specifiedNumbervalue to the document builder.EnhancedDocument.BuilderputNumberSet(String attributeName, Set<Number> values)Appends an attribute of name attributeName with specified Set ofNumbervalues to the document builder.EnhancedDocument.BuilderputObject(String attributeName, Object value)EnhancedDocument.BuilderputString(String attributeName, String value)Appends an attribute of name attributeName with specifiedStringvalue to the document builder.EnhancedDocument.BuilderputStringSet(String attributeName, Set<String> values)Appends an attribute to the document builder with a Set of Strings as its value.EnhancedDocument.Builderremove(String attributeName)Removes a previously appended attribute.
-
-
-
Constructor Detail
-
DefaultBuilder
public DefaultBuilder(DefaultEnhancedDocument enhancedDocument)
-
-
Method Detail
-
putObject
public EnhancedDocument.Builder putObject(String attributeName, Object value)
-
putString
public EnhancedDocument.Builder putString(String attributeName, String value)
Description copied from interface:EnhancedDocument.BuilderAppends an attribute of name attributeName with specifiedStringvalue 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- Specified by:
putStringin interfaceEnhancedDocument.Builder- 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
public EnhancedDocument.Builder putNumber(String attributeName, Number value)
Description copied from interface:EnhancedDocument.BuilderAppends an attribute of name attributeName with specifiedNumbervalue 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- Specified by:
putNumberin interfaceEnhancedDocument.Builder- 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
public EnhancedDocument.Builder putBytes(String attributeName, SdkBytes value)
Description copied from interface:EnhancedDocument.BuilderAppends an attribute of name attributeName with specifiedSdkBytesvalue 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- Specified by:
putBytesin interfaceEnhancedDocument.Builder- 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
public EnhancedDocument.Builder putBoolean(String attributeName, boolean value)
Description copied from interface:EnhancedDocument.BuilderUse 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.- Specified by:
putBooleanin interfaceEnhancedDocument.Builder- 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
public EnhancedDocument.Builder putNull(String attributeName)
Description copied from interface:EnhancedDocument.BuilderAppends 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.- Specified by:
putNullin interfaceEnhancedDocument.Builder- Parameters:
attributeName- the name of the attribute to be added to the document.- Returns:
- Builder instance to construct a
EnhancedDocument
-
putStringSet
public EnhancedDocument.Builder putStringSet(String attributeName, Set<String> values)
Description copied from interface:EnhancedDocument.BuilderAppends 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.- Specified by:
putStringSetin interfaceEnhancedDocument.Builder- 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
public EnhancedDocument.Builder putNumberSet(String attributeName, Set<Number> values)
Description copied from interface:EnhancedDocument.BuilderAppends an attribute of name attributeName with specified Set ofNumbervalues to the document builder.- Specified by:
putNumberSetin interfaceEnhancedDocument.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
public EnhancedDocument.Builder putBytesSet(String attributeName, Set<SdkBytes> values)
Description copied from interface:EnhancedDocument.BuilderAppends an attribute of name attributeName with specified Set ofSdkBytesvalues to the document builder.- Specified by:
putBytesSetin interfaceEnhancedDocument.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
public <T> EnhancedDocument.Builder putList(String attributeName, List<T> value, EnhancedType<T> type)
Description copied from interface:EnhancedDocument.BuilderAppends an attribute with the specified name and a list ofEnhancedTypeT 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:
Example for inserting a List of Custom type . Note that the AttributeConverterProvider added to the DocumentBuilder should provide the converter for the class T that is to be inserted.
- Specified by:
putListin interfaceEnhancedDocument.Builder- 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
public <T> EnhancedDocument.Builder put(String attributeName, T value, EnhancedType<T> type)
Description copied from interface:EnhancedDocument.BuilderAppends an attribute namedattributeNamewith a value of typeEnhancedTypeT. Use this method to insert attribute values of custom types that have attribute converters defined in a converter provider. Example: UseEnhancedDocument.Builder.putString(String, String)orEnhancedDocument.Builder.putNumber(String, Number)for inserting simple value types of attributes. UseEnhancedDocument.Builder.putList(String, List, EnhancedType)orEnhancedDocument.Builder.putMap(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.- Specified by:
putin interfaceEnhancedDocument.Builder- 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
public <T> EnhancedDocument.Builder put(String attributeName, T value, Class<T> type)
Description copied from interface:EnhancedDocument.BuilderAppends an attribute namedattributeNamewith 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: UseEnhancedDocument.Builder.putString(String, String)orEnhancedDocument.Builder.putNumber(String, Number)for inserting simple value types of attributes. UseEnhancedDocument.Builder.putList(String, List, EnhancedType)orEnhancedDocument.Builder.putMap(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.- Specified by:
putin interfaceEnhancedDocument.Builder- 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
public <K,V> EnhancedDocument.Builder putMap(String attributeName, Map<K,V> value, EnhancedType<K> keyType, EnhancedType<V> valueType)
Description copied from interface:EnhancedDocument.BuilderAppends an attribute with the specified name and a Map containing keys and values ofEnhancedTypeK 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:
For example, to insert a map of String Key and Custom Values: Note that the AttributeConverterProvider added to the DocumentBuilder should provide the converter for the classes K and V that are to be inserted.
- Specified by:
putMapin interfaceEnhancedDocument.Builder- 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
public EnhancedDocument.Builder putJson(String attributeName, String json)
Description copied from interface:EnhancedDocument.BuilderAppends an attribute to the document builder with the specified name and value of a JSON document in string format.- Specified by:
putJsonin interfaceEnhancedDocument.Builder- 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
public EnhancedDocument.Builder remove(String attributeName)
Description copied from interface:EnhancedDocument.BuilderRemoves a previously appended attribute. This can be used where a previously added attribute to the Builder is no longer needed.- Specified by:
removein interfaceEnhancedDocument.Builder- Parameters:
attributeName- The attribute that needs to be removed.- Returns:
- Builder instance to construct a
EnhancedDocument
-
addAttributeConverterProvider
public EnhancedDocument.Builder addAttributeConverterProvider(AttributeConverterProvider attributeConverterProvider)
Description copied from interface:EnhancedDocument.BuilderAppends 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.- Specified by:
addAttributeConverterProviderin interfaceEnhancedDocument.Builder- Parameters:
attributeConverterProvider- determining theAttributeConverterto use for converting a value.- Returns:
- Builder instance to construct a
EnhancedDocument
-
attributeConverterProviders
public EnhancedDocument.Builder attributeConverterProviders(List<AttributeConverterProvider> attributeConverterProviders)
Description copied from interface:EnhancedDocument.BuilderSets 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.- Specified by:
attributeConverterProvidersin interfaceEnhancedDocument.Builder- Parameters:
attributeConverterProviders- determining theAttributeConverterto use for converting a value.- Returns:
- Builder instance to construct a
EnhancedDocument
-
attributeConverterProviders
public EnhancedDocument.Builder attributeConverterProviders(AttributeConverterProvider... attributeConverterProviders)
Description copied from interface:EnhancedDocument.BuilderSets 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.- Specified by:
attributeConverterProvidersin interfaceEnhancedDocument.Builder- Parameters:
attributeConverterProviders- determining theAttributeConverterto use for converting a value.- Returns:
- Builder instance to construct a
EnhancedDocument
-
json
public EnhancedDocument.Builder json(String json)
Description copied from interface:EnhancedDocument.BuilderSets the attributes of the document builder to those specified in the provided JSON string, and completely replaces any previously set attributes.- Specified by:
jsonin interfaceEnhancedDocument.Builder- Parameters:
json- a JSON document represented as a string- Returns:
- a builder instance to construct a
EnhancedDocument
-
attributeValueMap
public EnhancedDocument.Builder attributeValueMap(Map<String,AttributeValue> attributeValueMap)
Description copied from interface:EnhancedDocument.BuilderSets the attributes of the document builder to those specified in the provided from a AttributeValue Map, and completely replaces any previously set attributes.- Specified by:
attributeValueMapin interfaceEnhancedDocument.Builder- Parameters:
attributeValueMap- - Map with Attributes as String keys and AttributeValue as Value.- Returns:
- Builder instance to construct a
EnhancedDocument
-
build
public EnhancedDocument build()
Description copied from interface:EnhancedDocument.BuilderBuilds an instance ofEnhancedDocument.- Specified by:
buildin interfaceEnhancedDocument.Builder- Returns:
- instance of
EnhancedDocumentimplementation.
-
-