Class EnumAttributeConverter<T extends Enum<T>>
java.lang.Object
software.amazon.awssdk.enhanced.dynamodb.EnumAttributeConverter<T>
- All Implemented Interfaces:
AttributeConverter<T>
public final class EnumAttributeConverter<T extends Enum<T>>
extends Object
implements AttributeConverter<T>
A converter between an
Enum
and AttributeValue
.
This stores values in DynamoDB as a string.
Use EnumAttributeConverter::create in order to use Enum::toString as the enum identifier
Use EnumAttributeConverter::createWithNameAsKeys in order to use Enum::name as the enum identifier
This can be created via create(Class)
.
-
Method Summary
Modifier and TypeMethodDescriptionReturns theAttributeValueType
of the converter.static <T extends Enum<T>>
EnumAttributeConverter<T> Creates an EnumAttributeConverter for anEnum
.static <T extends Enum<T>>
EnumAttributeConverter<T> createWithNameAsKeys
(Class<T> enumClass) Creates an EnumAttributeConverter for anEnum
.transformFrom
(T input) Returns the properAttributeValue
for the given enum type.transformTo
(AttributeValue input) Returns the proper enum type for the givenAttributeValue
input.type()
Returns theEnhancedType
of the converter.
-
Method Details
-
create
Creates an EnumAttributeConverter for anEnum
.Uses Enum::toString as the enum identifier.
- Type Parameters:
T
- the enum subclass- Parameters:
enumClass
- The enum class to be used- Returns:
- an EnumAttributeConverter
-
createWithNameAsKeys
public static <T extends Enum<T>> EnumAttributeConverter<T> createWithNameAsKeys(Class<T> enumClass) Creates an EnumAttributeConverter for anEnum
.Uses Enum::name as the enum identifier.
- Type Parameters:
T
- the enum subclass- Parameters:
enumClass
- The enum class to be used- Returns:
- an EnumAttributeConverter
-
transformFrom
Returns the properAttributeValue
for the given enum type.- Specified by:
transformFrom
in interfaceAttributeConverter<T extends Enum<T>>
- Parameters:
input
- the enum type to be converted- Returns:
- AttributeValue
-
transformTo
Returns the proper enum type for the givenAttributeValue
input.- Specified by:
transformTo
in interfaceAttributeConverter<T extends Enum<T>>
- Parameters:
input
- the AttributeValue to be converted- Returns:
- an enum type
-
type
Returns theEnhancedType
of the converter.- Specified by:
type
in interfaceAttributeConverter<T extends Enum<T>>
- Returns:
- EnhancedType
-
attributeValueType
Returns theAttributeValueType
of the converter.- Specified by:
attributeValueType
in interfaceAttributeConverter<T extends Enum<T>>
- Returns:
- AttributeValueType
-