Class EnhancedAttributeValue
- java.lang.Object
-
- software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute.EnhancedAttributeValue
-
@ThreadSafe @Immutable public final class EnhancedAttributeValue extends Object
A simpler, and more user-friendly version of the generatedAttributeValue.This is a union type of the types exposed by DynamoDB, exactly as they're exposed by DynamoDB.
An instance of
EnhancedAttributeValuerepresents exactly one DynamoDB type, like String (s), Number (n) or Bytes (b). This type can be determined with thetype()method or theis*methods likeisString()orisNumber(). Once the type is known, the value can be extracted withas*methods likeasString()orasNumber().When converting an
EnhancedAttributeValueinto a concrete Java type, it can be tedious to use thetype()oris*methods. For this reason, aconvert(TypeConvertingVisitor)method is provided that exposes a polymorphic way of converting a value into another type.An instance of
EnhancedAttributeValueis created with thefrom*methods, likefromString(String)orfromNumber(String).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BooleanasBoolean()Retrieve this value as a boolean.SdkBytesasBytes()Retrieve this value as bytes.List<AttributeValue>asListOfAttributeValues()Retrieve this value as a list of attribute values.Map<String,AttributeValue>asMap()Retrieve this value as a map.StringasNumber()Retrieve this value as a number.List<SdkBytes>asSetOfBytes()Retrieve this value as a set of bytes.List<String>asSetOfNumbers()Retrieve this value as a set of numbers.List<String>asSetOfStrings()Retrieve this value as a set of strings.StringasString()Retrieve this value as a string.<T> Tconvert(TypeConvertingVisitor<T> convertingVisitor)Apply the provided visitor to this item attribute value, converting it into a specific type.booleanequals(Object o)static EnhancedAttributeValuefromAttributeValue(AttributeValue attributeValue)Create anEnhancedAttributeValuefrom a generatedAttributeValue.static EnhancedAttributeValuefromBoolean(Boolean booleanValue)Create anEnhancedAttributeValuefor a boolean (bool) DynamoDB type.static EnhancedAttributeValuefromBytes(SdkBytes bytesValue)Create anEnhancedAttributeValuefor a bytes (b) DynamoDB type.static EnhancedAttributeValuefromListOfAttributeValues(List<AttributeValue> listOfAttributeValuesValue)Create anEnhancedAttributeValuefor a list-of-attributes (l) DynamoDB type.static EnhancedAttributeValuefromListOfAttributeValues(AttributeValue... listOfAttributeValuesValue)Create anEnhancedAttributeValuefor a list-of-attributes (l) DynamoDB type.static EnhancedAttributeValuefromMap(Map<String,AttributeValue> mapValue)Create anEnhancedAttributeValuefor a map (m) DynamoDB type.static EnhancedAttributeValuefromNumber(String numberValue)Create anEnhancedAttributeValuefor a number (n) DynamoDB type.static EnhancedAttributeValuefromSetOfBytes(Collection<SdkBytes> setOfBytesValue)Create anEnhancedAttributeValuefor a set-of-bytes (bs) DynamoDB type.static EnhancedAttributeValuefromSetOfBytes(List<SdkBytes> setOfBytesValue)Create anEnhancedAttributeValuefor a set-of-bytes (bs) DynamoDB type.static EnhancedAttributeValuefromSetOfBytes(SdkBytes... setOfBytesValue)Create anEnhancedAttributeValuefor a set-of-bytes (bs) DynamoDB type.static EnhancedAttributeValuefromSetOfNumbers(String... setOfNumbersValue)Create anEnhancedAttributeValuefor a set-of-numbers (ns) DynamoDB type.static EnhancedAttributeValuefromSetOfNumbers(Collection<String> setOfNumbersValue)Create anEnhancedAttributeValuefor a set-of-numbers (ns) DynamoDB type.static EnhancedAttributeValuefromSetOfNumbers(List<String> setOfNumbersValue)Create anEnhancedAttributeValuefor a set-of-numbers (ns) DynamoDB type.static EnhancedAttributeValuefromSetOfStrings(String... setOfStringsValue)Create anEnhancedAttributeValuefor a set-of-strings (ss) DynamoDB type.static EnhancedAttributeValuefromSetOfStrings(Collection<String> setOfStringsValue)Create anEnhancedAttributeValuefor a set-of-strings (ss) DynamoDB type.static EnhancedAttributeValuefromSetOfStrings(List<String> setOfStringsValue)Create anEnhancedAttributeValuefor a set-of-strings (ss) DynamoDB type.static EnhancedAttributeValuefromString(String stringValue)Create anEnhancedAttributeValuefor a string (s) DynamoDB type.inthashCode()booleanisBoolean()Returns true if the underlying DynamoDB type of this value is a Boolean (bool).booleanisBytes()Returns true if the underlying DynamoDB type of this value is Bytes (b).booleanisListOfAttributeValues()Returns true if the underlying DynamoDB type of this value is a List of AttributeValues (l).booleanisMap()Returns true if the underlying DynamoDB type of this value is a Map (m).booleanisNull()Returns true if the underlying DynamoDB type of this value is Null (null).booleanisNumber()Returns true if the underlying DynamoDB type of this value is a Number (n).booleanisSetOfBytes()Returns true if the underlying DynamoDB type of this value is a Set of Bytes (bs).booleanisSetOfNumbers()Returns true if the underlying DynamoDB type of this value is a Set of Numbers (ns).booleanisSetOfStrings()Returns true if the underlying DynamoDB type of this value is a Set of Strings (ss).booleanisString()Returns true if the underlying DynamoDB type of this value is a String (s).static EnhancedAttributeValuenullValue()Create anEnhancedAttributeValuefor the null DynamoDB type.AttributeValuetoAttributeValue()Convert thisEnhancedAttributeValueinto a generatedAttributeValue.Map<String,AttributeValue>toAttributeValueMap()Convert thisEnhancedAttributeValueinto a generatedMap<String, AttributeValue>.StringtoString()AttributeValueTypetype()Retrieve the underlying DynamoDB type of this value, such as String (s) or Number (n).
-
-
-
Method Detail
-
nullValue
public static EnhancedAttributeValue nullValue()
Create anEnhancedAttributeValuefor the null DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().nul(true).build())This call should never fail with an
Exception.
-
fromMap
public static EnhancedAttributeValue fromMap(Map<String,AttributeValue> mapValue)
Create anEnhancedAttributeValuefor a map (m) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().m(...).build())This call will fail with a
RuntimeExceptionif the provided map is null or has null keys.
-
fromString
public static EnhancedAttributeValue fromString(String stringValue)
Create anEnhancedAttributeValuefor a string (s) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().s(...).build())This call will fail with a
RuntimeExceptionif the provided value is null. UsenullValue()for null values.
-
fromNumber
public static EnhancedAttributeValue fromNumber(String numberValue)
Create anEnhancedAttributeValuefor 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
RuntimeExceptionif the provided value is null. UsenullValue()for null values.
-
fromBytes
public static EnhancedAttributeValue fromBytes(SdkBytes bytesValue)
Create anEnhancedAttributeValuefor a bytes (b) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().b(...).build())This call will fail with a
RuntimeExceptionif the provided value is null. UsenullValue()for null values.
-
fromBoolean
public static EnhancedAttributeValue fromBoolean(Boolean booleanValue)
Create anEnhancedAttributeValuefor a boolean (bool) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bool(...).build())This call will fail with a
RuntimeExceptionif the provided value is null. UsenullValue()for null values.
-
fromSetOfStrings
public static EnhancedAttributeValue fromSetOfStrings(String... setOfStringsValue)
Create anEnhancedAttributeValuefor a set-of-strings (ss) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ss(...).build())This call will fail with a
RuntimeExceptionif 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
public static EnhancedAttributeValue fromSetOfStrings(Collection<String> setOfStringsValue)
Create anEnhancedAttributeValuefor a set-of-strings (ss) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ss(...).build())This call will fail with a
RuntimeExceptionif 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
public static EnhancedAttributeValue fromSetOfStrings(List<String> setOfStringsValue)
Create anEnhancedAttributeValuefor a set-of-strings (ss) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ss(...).build())This call will fail with a
RuntimeExceptionif 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
public static EnhancedAttributeValue fromSetOfNumbers(String... setOfNumbersValue)
Create anEnhancedAttributeValuefor a set-of-numbers (ns) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ns(...).build())This call will fail with a
RuntimeExceptionif 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
public static EnhancedAttributeValue fromSetOfNumbers(Collection<String> setOfNumbersValue)
Create anEnhancedAttributeValuefor a set-of-numbers (ns) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ns(...).build())This call will fail with a
RuntimeExceptionif 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
public static EnhancedAttributeValue fromSetOfNumbers(List<String> setOfNumbersValue)
Create anEnhancedAttributeValuefor a set-of-numbers (ns) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ns(...).build())This call will fail with a
RuntimeExceptionif 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
public static EnhancedAttributeValue fromSetOfBytes(Collection<SdkBytes> setOfBytesValue)
Create anEnhancedAttributeValuefor a set-of-bytes (bs) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bs(...).build())This call will fail with a
RuntimeExceptionif 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
public static EnhancedAttributeValue fromSetOfBytes(SdkBytes... setOfBytesValue)
Create anEnhancedAttributeValuefor a set-of-bytes (bs) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bs(...).build())This call will fail with a
RuntimeExceptionif 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
public static EnhancedAttributeValue fromSetOfBytes(List<SdkBytes> setOfBytesValue)
Create anEnhancedAttributeValuefor a set-of-bytes (bs) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bs(...).build())This call will fail with a
RuntimeExceptionif 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 anEnhancedAttributeValuefor a list-of-attributes (l) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().l(...).build())This call will fail with a
RuntimeExceptionif the provided value is null or contains a null value. UsenullValue()for null values.
-
fromListOfAttributeValues
public static EnhancedAttributeValue fromListOfAttributeValues(List<AttributeValue> listOfAttributeValuesValue)
Create anEnhancedAttributeValuefor a list-of-attributes (l) DynamoDB type.Equivalent to:
EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().l(...).build())This call will fail with a
RuntimeExceptionif the provided value is null or contains a null value. UsenullValue()for null values.
-
fromAttributeValue
public static EnhancedAttributeValue fromAttributeValue(AttributeValue attributeValue)
Create anEnhancedAttributeValuefrom a generatedAttributeValue.This call will fail with a
RuntimeExceptionif the provided value is null (AttributeValue.nul()is okay).
-
type
public AttributeValueType 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
public <T> T convert(TypeConvertingVisitor<T> convertingVisitor)
Apply the provided visitor to this item attribute value, converting it into a specific type. This is useful inAttributeConverterimplementations, 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
public Map<String,AttributeValue> asMap()
Retrieve this value as a map.This call will fail with a
RuntimeExceptionifisMap()is false.
-
asString
public String asString()
Retrieve this value as a string.This call will fail with a
RuntimeExceptionifisString()is false.
-
asNumber
public String 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
RuntimeExceptionifisNumber()is false.
-
asBytes
public SdkBytes asBytes()
Retrieve this value as bytes.This call will fail with a
RuntimeExceptionifisBytes()is false.
-
asBoolean
public Boolean asBoolean()
Retrieve this value as a boolean.This call will fail with a
RuntimeExceptionifisBoolean()is false.
-
asSetOfStrings
public List<String> 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
RuntimeExceptionifisSetOfStrings()is false.
-
asSetOfNumbers
public List<String> 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
RuntimeExceptionifisSetOfNumbers()is false.
-
asSetOfBytes
public List<SdkBytes> 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
RuntimeExceptionifisSetOfBytes()is false.
-
asListOfAttributeValues
public List<AttributeValue> asListOfAttributeValues()
Retrieve this value as a list of attribute values.This call will fail with a
RuntimeExceptionifisListOfAttributeValues()is false.
-
toAttributeValueMap
public Map<String,AttributeValue> toAttributeValueMap()
Convert thisEnhancedAttributeValueinto a generatedMap<String, AttributeValue>.This call will fail with a
RuntimeExceptionifisMap()is false.
-
toAttributeValue
public AttributeValue toAttributeValue()
Convert thisEnhancedAttributeValueinto a generatedAttributeValue.This call should never fail with an
Exception.
-
-