@Immutable public class DefaultEnhancedDocument extends Object implements EnhancedDocument
EnhancedDocument used by the SDK to create Enhanced Documents. Attributes are initially saved
as a String-Object Map when documents are created using the builder. Conversion to an AttributeValueMap is done lazily when
values are accessed. When the document is retrieved from DynamoDB, the AttributeValueMap is internally saved as the attribute
value map. Custom objects or collections are saved in the enhancedTypeMap to preserve the generic class information. Note that
no default ConverterProviders are assigned, so ConverterProviders must be passed in the builder when creating enhanced
documents.| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultEnhancedDocument.DefaultBuilder |
EnhancedDocument.Builder| Constructor and Description |
|---|
DefaultEnhancedDocument(DefaultEnhancedDocument.DefaultBuilder builder) |
| Modifier and Type | Method and Description |
|---|---|
List<AttributeConverterProvider> |
attributeConverterProviders() |
static EnhancedDocument.Builder |
builder()
Creates a default builder for
EnhancedDocument. |
static <T> AttributeConverter<T> |
converterForClass(EnhancedType<T> type,
ChainConverterProvider chainConverterProvider) |
boolean |
equals(Object o) |
<T> T |
get(String attributeName,
Class<T> clazz)
Returns the value of the specified attribute in the current document as a specified class type; or null if the
attribute either doesn't exist or the attribute value is null.
|
<T> T |
get(String attributeName,
EnhancedType<T> type)
Returns the value of the specified attribute in the current document as a specified
EnhancedType; or null if the
attribute either doesn't exist or the attribute value is null. |
Boolean |
getBoolean(String attributeName)
Gets the
Boolean value for the specified attribute. |
SdkBytes |
getBytes(String attributeName)
Gets the
SdkBytes value of specified attribute in the document. |
Set<SdkBytes> |
getBytesSet(String attributeName)
Gets the Set of String values of the given attribute in the current document.
|
String |
getJson(String attributeName)
Gets the JSON document value of the specified attribute.
|
<T> List<T> |
getList(String attributeName,
EnhancedType<T> type)
Gets the List of values of type T for the given attribute in the current document.
|
List<AttributeValue> |
getListOfUnknownType(String attributeName)
Retrieves a list of
AttributeValue objects for a specified attribute in a document. |
<K,V> Map<K,V> |
getMap(String attributeName,
EnhancedType<K> keyType,
EnhancedType<V> valueType)
Returns a map of a specific Key-type and Value-type based on the given attribute name, key type, and value type.
|
Map<String,AttributeValue> |
getMapOfUnknownType(String attributeName)
Retrieves a Map with String keys and corresponding AttributeValue objects as values for a specified attribute in a
document.
|
SdkNumber |
getNumber(String attributeName)
Gets the
SdkNumber value of specified attribute in the document. |
Set<SdkNumber> |
getNumberSet(String attributeName)
Gets the Set of String values of the given attribute in the current document.
|
String |
getString(String attributeName)
Gets the String value of specified attribute in the document.
|
Set<String> |
getStringSet(String attributeName)
Gets the Set of String values of the given attribute in the current document.
|
int |
hashCode() |
boolean |
isNull(String attributeName)
Checks if the document is a
null value. |
boolean |
isPresent(String attributeName)
Checks if the attribute exists in the document.
|
EnhancedDocument.Builder |
toBuilder()
Converts an existing EnhancedDocument into a builder object that can be used to modify its values and then create a new
EnhancedDocument.
|
String |
toJson() |
Map<String,AttributeValue> |
toMap()
This method converts a document into a key-value map with the keys as String objects and the values as AttributeValue
objects.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitfromAttributeValueMap, fromJsonpublic DefaultEnhancedDocument(DefaultEnhancedDocument.DefaultBuilder builder)
public static EnhancedDocument.Builder builder()
EnhancedDocumentEnhancedDocument.builder in interface EnhancedDocumentpublic static <T> AttributeConverter<T> converterForClass(EnhancedType<T> type, ChainConverterProvider chainConverterProvider)
public EnhancedDocument.Builder toBuilder()
EnhancedDocumenttoBuilder in interface EnhancedDocumentEnhancedDocument.Builder initialized with the values of this EnhancedDocument.public List<AttributeConverterProvider> attributeConverterProviders()
attributeConverterProviders in interface EnhancedDocumentpublic boolean isNull(String attributeName)
EnhancedDocumentnull value.isNull in interface EnhancedDocumentattributeName - Name of the attribute that needs to be checked.public boolean isPresent(String attributeName)
EnhancedDocumentisPresent in interface EnhancedDocumentattributeName - Name of the attribute that needs to be checked.public <T> T get(String attributeName, EnhancedType<T> type)
EnhancedDocumentEnhancedType; or null if the
attribute either doesn't exist or the attribute value is null.
Retrieving String Type for a document Retrieving Custom Type for which Convertor Provider was defined while creating the document Retrieving list of strings in a document Retrieving a Map with List of strings in its values
get in interface EnhancedDocumentT - The type of the attribute value.attributeName - Name of the attribute.type - EnhancedType of the valuepublic String getString(String attributeName)
EnhancedDocumentgetString in interface EnhancedDocumentattributeName - Name of the attribute.public SdkNumber getNumber(String attributeName)
EnhancedDocumentSdkNumber value of specified attribute in the document.getNumber in interface EnhancedDocumentattributeName - Name of the attribute.public <T> T get(String attributeName, Class<T> clazz)
EnhancedDocumentRetrieving String Type for a document Retrieving Custom Type for which Convertor Provider was defined while creating the document
Note : This API should not be used to retrieve values of List and Map types. Instead, getList and getMap APIs should be used to retrieve attributes of type List and Map, respectively.
get in interface EnhancedDocumentT - The type of the attribute value.attributeName - Name of the attribute.clazz - Class type of value.public SdkBytes getBytes(String attributeName)
EnhancedDocumentSdkBytes value of specified attribute in the document.getBytes in interface EnhancedDocumentattributeName - Name of the attribute.public Set<String> getStringSet(String attributeName)
EnhancedDocumentgetStringSet in interface EnhancedDocumentattributeName - the name of the attribute.public Set<SdkNumber> getNumberSet(String attributeName)
EnhancedDocumentgetNumberSet in interface EnhancedDocumentattributeName - Name of the attribute.public Set<SdkBytes> getBytesSet(String attributeName)
EnhancedDocumentgetBytesSet in interface EnhancedDocumentattributeName - Name of the attribute.public <T> List<T> getList(String attributeName, EnhancedType<T> type)
EnhancedDocumentgetList in interface EnhancedDocumentT - Type T of List elementsattributeName - Name of the attribute.type - EnhancedType of Type T.public <K,V> Map<K,V> getMap(String attributeName, EnhancedType<K> keyType, EnhancedType<V> valueType)
EnhancedDocumentUUID keys and Integer values, use this API
as shown below:
getMap in interface EnhancedDocumentK - The type of the Map keys.V - The type of the Map values.attributeName - The name of the attribute that needs to be get as Map.keyType - Enhanced Type of Key attribute, like String, UUID etc that can be represented as String Keys.valueType - Enhanced Type of Values , which have converters defineds in
EnhancedDocument.Builder.attributeConverterProviders(AttributeConverterProvider...) for the documentpublic String getJson(String attributeName)
EnhancedDocumentgetJson in interface EnhancedDocumentattributeName - Name of the attribute.public Boolean getBoolean(String attributeName)
EnhancedDocumentBoolean value for the specified attribute.getBoolean in interface EnhancedDocumentattributeName - Name of the attribute.public List<AttributeValue> getListOfUnknownType(String attributeName)
EnhancedDocumentAttributeValue objects for a specified attribute in a document.
This API should be used when the elements of the list are a combination of different types such as Strings, Maps,
and Numbers.
If all elements in the list are of a known fixed type, use EnhancedDocument.getList(String, EnhancedType) instead.getListOfUnknownType in interface EnhancedDocumentattributeName - Name of the attribute.AttributeValuepublic Map<String,AttributeValue> getMapOfUnknownType(String attributeName)
EnhancedDocumentgetMapOfUnknownType in interface EnhancedDocumentattributeName - Name of the attribute.AttributeValuepublic String toJson()
toJson in interface EnhancedDocumentpublic Map<String,AttributeValue> toMap()
EnhancedDocumenttoMap in interface EnhancedDocumentCopyright © 2023. All rights reserved.