Class EnhancedAttributeValue
AttributeValue
.
This is a union type of the types exposed by DynamoDB, exactly as they're exposed by DynamoDB.
An instance of EnhancedAttributeValue
represents exactly one DynamoDB type, like String (s), Number (n) or Bytes (b).
This type can be determined with the type()
method or the is*
methods like isString()
or
isNumber()
. Once the type is known, the value can be extracted with as*
methods like asString()
or asNumber()
.
When converting an EnhancedAttributeValue
into a concrete Java type, it can be tedious to use the type()
or
is*
methods. For this reason, a convert(TypeConvertingVisitor)
method is provided that exposes a polymorphic
way of converting a value into another type.
An instance of EnhancedAttributeValue
is created with the from*
methods, like fromString(String)
or
fromNumber(String)
.
-
Method Summary
Modifier and TypeMethodDescriptionRetrieve this value as a boolean.asBytes()
Retrieve this value as bytes.Retrieve this value as a list of attribute values.asMap()
Retrieve this value as a map.asNumber()
Retrieve this value as a number.Retrieve this value as a set of bytes.Retrieve this value as a set of numbers.Retrieve this value as a set of strings.asString()
Retrieve this value as a string.<T> T
convert
(TypeConvertingVisitor<T> convertingVisitor) Apply the provided visitor to this item attribute value, converting it into a specific type.boolean
static EnhancedAttributeValue
fromAttributeValue
(AttributeValue attributeValue) Create anEnhancedAttributeValue
from a generatedAttributeValue
.static EnhancedAttributeValue
fromBoolean
(Boolean booleanValue) Create anEnhancedAttributeValue
for a boolean (bool) DynamoDB type.static EnhancedAttributeValue
Create anEnhancedAttributeValue
for a bytes (b) DynamoDB type.static EnhancedAttributeValue
fromListOfAttributeValues
(List<AttributeValue> listOfAttributeValuesValue) Create anEnhancedAttributeValue
for a list-of-attributes (l) DynamoDB type.static EnhancedAttributeValue
fromListOfAttributeValues
(AttributeValue... listOfAttributeValuesValue) Create anEnhancedAttributeValue
for a list-of-attributes (l) DynamoDB type.static EnhancedAttributeValue
fromMap
(Map<String, AttributeValue> mapValue) Create anEnhancedAttributeValue
for a map (m) DynamoDB type.static EnhancedAttributeValue
fromNumber
(String numberValue) Create anEnhancedAttributeValue
for a number (n) DynamoDB type.static EnhancedAttributeValue
fromSetOfBytes
(Collection<SdkBytes> setOfBytesValue) Create anEnhancedAttributeValue
for a set-of-bytes (bs) DynamoDB type.static EnhancedAttributeValue
fromSetOfBytes
(List<SdkBytes> setOfBytesValue) Create anEnhancedAttributeValue
for a set-of-bytes (bs) DynamoDB type.static EnhancedAttributeValue
fromSetOfBytes
(SdkBytes... setOfBytesValue) Create anEnhancedAttributeValue
for a set-of-bytes (bs) DynamoDB type.static EnhancedAttributeValue
fromSetOfNumbers
(String... setOfNumbersValue) Create anEnhancedAttributeValue
for a set-of-numbers (ns) DynamoDB type.static EnhancedAttributeValue
fromSetOfNumbers
(Collection<String> setOfNumbersValue) Create anEnhancedAttributeValue
for a set-of-numbers (ns) DynamoDB type.static EnhancedAttributeValue
fromSetOfNumbers
(List<String> setOfNumbersValue) Create anEnhancedAttributeValue
for a set-of-numbers (ns) DynamoDB type.static EnhancedAttributeValue
fromSetOfStrings
(String... setOfStringsValue) Create anEnhancedAttributeValue
for a set-of-strings (ss) DynamoDB type.static EnhancedAttributeValue
fromSetOfStrings
(Collection<String> setOfStringsValue) Create anEnhancedAttributeValue
for a set-of-strings (ss) DynamoDB type.static EnhancedAttributeValue
fromSetOfStrings
(List<String> setOfStringsValue) Create anEnhancedAttributeValue
for a set-of-strings (ss) DynamoDB type.static EnhancedAttributeValue
fromString
(String stringValue) Create anEnhancedAttributeValue
for a string (s) DynamoDB type.int
hashCode()
boolean
Returns true if the underlying DynamoDB type of this value is a Boolean (bool).boolean
isBytes()
Returns true if the underlying DynamoDB type of this value is Bytes (b).boolean
Returns true if the underlying DynamoDB type of this value is a List of AttributeValues (l).boolean
isMap()
Returns true if the underlying DynamoDB type of this value is a Map (m).boolean
isNull()
Returns true if the underlying DynamoDB type of this value is Null (null).boolean
isNumber()
Returns true if the underlying DynamoDB type of this value is a Number (n).boolean
Returns true if the underlying DynamoDB type of this value is a Set of Bytes (bs).boolean
Returns true if the underlying DynamoDB type of this value is a Set of Numbers (ns).boolean
Returns true if the underlying DynamoDB type of this value is a Set of Strings (ss).boolean
isString()
Returns true if the underlying DynamoDB type of this value is a String (s).static EnhancedAttributeValue
Create anEnhancedAttributeValue
for the null DynamoDB type.Convert thisEnhancedAttributeValue
into a generatedAttributeValue
.Convert thisEnhancedAttributeValue
into a generatedMap<String, AttributeValue>
.toString()
type()
Retrieve the underlying DynamoDB type of this value, such as String (s) or Number (n).
-
Method Details
-
nullValue
Create anEnhancedAttributeValue
for the null DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().nul(true).build())
This call should never fail with an
Exception
. -
fromMap
Create anEnhancedAttributeValue
for a map (m) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().m(...).build())
This call will fail with a
RuntimeException
if the provided map is null or has null keys. -
fromString
Create anEnhancedAttributeValue
for a string (s) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().s(...).build())
This call will fail with a
RuntimeException
if the provided value is null. UsenullValue()
for null values. -
fromNumber
Create anEnhancedAttributeValue
for a number (n) DynamoDB type.This is a String, because it matches the underlying DynamoDB representation.
Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().n(...).build())
This call will fail with a
RuntimeException
if the provided value is null. UsenullValue()
for null values. -
fromBytes
Create anEnhancedAttributeValue
for a bytes (b) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().b(...).build())
This call will fail with a
RuntimeException
if the provided value is null. UsenullValue()
for null values. -
fromBoolean
Create anEnhancedAttributeValue
for a boolean (bool) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bool(...).build())
This call will fail with a
RuntimeException
if the provided value is null. UsenullValue()
for null values. -
fromSetOfStrings
Create anEnhancedAttributeValue
for a set-of-strings (ss) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ss(...).build())
This call will fail with a
RuntimeException
if the provided value is null or contains a null value. UsefromListOfAttributeValues(List)
for null values. This will not validate that there are no duplicate values. -
fromSetOfStrings
Create anEnhancedAttributeValue
for a set-of-strings (ss) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ss(...).build())
This call will fail with a
RuntimeException
if the provided value is null or contains a null value. UsefromListOfAttributeValues(List)
for null values. This will not validate that there are no duplicate values. -
fromSetOfStrings
Create anEnhancedAttributeValue
for a set-of-strings (ss) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ss(...).build())
This call will fail with a
RuntimeException
if the provided value is null or contains a null value. UsefromListOfAttributeValues(List)
for null values. This will not validate that there are no duplicate values. -
fromSetOfNumbers
Create anEnhancedAttributeValue
for a set-of-numbers (ns) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ns(...).build())
This call will fail with a
RuntimeException
if the provided value is null or contains a null value. UsefromListOfAttributeValues(List)
for null values. This will not validate that there are no duplicate values. -
fromSetOfNumbers
Create anEnhancedAttributeValue
for a set-of-numbers (ns) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ns(...).build())
This call will fail with a
RuntimeException
if the provided value is null or contains a null value. UsefromListOfAttributeValues(List)
for null values. This will not validate that there are no duplicate values. -
fromSetOfNumbers
Create anEnhancedAttributeValue
for a set-of-numbers (ns) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ns(...).build())
This call will fail with a
RuntimeException
if the provided value is null or contains a null value. UsefromListOfAttributeValues(List)
for null values. This will not validate that there are no duplicate values. -
fromSetOfBytes
Create anEnhancedAttributeValue
for a set-of-bytes (bs) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bs(...).build())
This call will fail with a
RuntimeException
if the provided value is null or contains a null value. UsefromListOfAttributeValues(List)
for null values. This will not validate that there are no duplicate values. -
fromSetOfBytes
Create anEnhancedAttributeValue
for a set-of-bytes (bs) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bs(...).build())
This call will fail with a
RuntimeException
if the provided value is null or contains a null value. UsefromListOfAttributeValues(List)
for null values. This will not validate that there are no duplicate values. -
fromSetOfBytes
Create anEnhancedAttributeValue
for a set-of-bytes (bs) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bs(...).build())
This call will fail with a
RuntimeException
if the provided value is null or contains a null value. UsefromListOfAttributeValues(List)
for null values. This will not validate that there are no duplicate values. -
fromListOfAttributeValues
public static EnhancedAttributeValue fromListOfAttributeValues(AttributeValue... listOfAttributeValuesValue) Create anEnhancedAttributeValue
for a list-of-attributes (l) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().l(...).build())
This call will fail with a
RuntimeException
if the provided value is null or contains a null value. UsenullValue()
for null values. -
fromListOfAttributeValues
public static EnhancedAttributeValue fromListOfAttributeValues(List<AttributeValue> listOfAttributeValuesValue) Create anEnhancedAttributeValue
for a list-of-attributes (l) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().l(...).build())
This call will fail with a
RuntimeException
if the provided value is null or contains a null value. UsenullValue()
for null values. -
fromAttributeValue
Create anEnhancedAttributeValue
from a generatedAttributeValue
.This call will fail with a
RuntimeException
if the provided value is null (AttributeValue.nul()
is okay). -
type
Retrieve the underlying DynamoDB type of this value, such as String (s) or Number (n).This call should never fail with an
Exception
. -
convert
Apply the provided visitor to this item attribute value, converting it into a specific type. This is useful inAttributeConverter
implementations, without having to write a switch statement on thetype()
.Reasons this call may fail with a
RuntimeException
:- If the provided visitor is null.
- If the value cannot be converted by this visitor.
-
isMap
public boolean isMap()Returns true if the underlying DynamoDB type of this value is a Map (m).This call should never fail with an
Exception
. -
isString
public boolean isString()Returns true if the underlying DynamoDB type of this value is a String (s).This call should never fail with an
Exception
. -
isNumber
public boolean isNumber()Returns true if the underlying DynamoDB type of this value is a Number (n).This call should never fail with an
Exception
. -
isBytes
public boolean isBytes()Returns true if the underlying DynamoDB type of this value is Bytes (b).This call should never fail with an
Exception
. -
isBoolean
public boolean isBoolean()Returns true if the underlying DynamoDB type of this value is a Boolean (bool).This call should never fail with an
Exception
. -
isSetOfStrings
public boolean isSetOfStrings()Returns true if the underlying DynamoDB type of this value is a Set of Strings (ss).This call should never fail with an
Exception
. -
isSetOfNumbers
public boolean isSetOfNumbers()Returns true if the underlying DynamoDB type of this value is a Set of Numbers (ns).This call should never fail with an
Exception
. -
isSetOfBytes
public boolean isSetOfBytes()Returns true if the underlying DynamoDB type of this value is a Set of Bytes (bs).This call should never fail with an
Exception
. -
isListOfAttributeValues
public boolean isListOfAttributeValues()Returns true if the underlying DynamoDB type of this value is a List of AttributeValues (l).This call should never fail with an
Exception
. -
isNull
public boolean isNull()Returns true if the underlying DynamoDB type of this value is Null (null).This call should never fail with an
Exception
. -
asMap
Retrieve this value as a map.This call will fail with a
RuntimeException
ifisMap()
is false. -
asString
Retrieve this value as a string.This call will fail with a
RuntimeException
ifisString()
is false. -
asNumber
Retrieve this value as a number. Note: This returns aString
(instead of aNumber
), because that's the generated type from DynamoDB:AttributeValue.n()
.This call will fail with a
RuntimeException
ifisNumber()
is false. -
asBytes
Retrieve this value as bytes.This call will fail with a
RuntimeException
ifisBytes()
is false. -
asBoolean
Retrieve this value as a boolean.This call will fail with a
RuntimeException
ifisBoolean()
is false. -
asSetOfStrings
Retrieve this value as a set of strings.Note: This returns a
List
(instead of aSet
), because that's the generated type from DynamoDB:AttributeValue.ss()
.This call will fail with a
RuntimeException
ifisSetOfStrings()
is false. -
asSetOfNumbers
Retrieve this value as a set of numbers.Note: This returns a
List<String>
(instead of aSet<Number>
), because that's the generated type from DynamoDB:AttributeValue.ns()
.This call will fail with a
RuntimeException
ifisSetOfNumbers()
is false. -
asSetOfBytes
Retrieve this value as a set of bytes.Note: This returns a
List
(instead of aSet
), because that's the generated type from DynamoDB:AttributeValue.bs()
.This call will fail with a
RuntimeException
ifisSetOfBytes()
is false. -
asListOfAttributeValues
Retrieve this value as a list of attribute values.This call will fail with a
RuntimeException
ifisListOfAttributeValues()
is false. -
toAttributeValueMap
Convert thisEnhancedAttributeValue
into a generatedMap<String, AttributeValue>
.This call will fail with a
RuntimeException
ifisMap()
is false. -
toAttributeValue
Convert thisEnhancedAttributeValue
into a generatedAttributeValue
.This call should never fail with an
Exception
. -
equals
-
hashCode
public int hashCode() -
toString
-