public final class EnumAttributeConverter<T extends Enum<T>> extends Object implements AttributeConverter<T>
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).
| Modifier and Type | Method and Description |
|---|---|
AttributeValueType |
attributeValueType()
Returns the
AttributeValueType of the converter. |
static <T extends Enum<T>> |
create(Class<T> enumClass)
Creates an EnumAttributeConverter for an
Enum. |
static <T extends Enum<T>> |
createWithNameAsKeys(Class<T> enumClass)
Creates an EnumAttributeConverter for an
Enum. |
AttributeValue |
transformFrom(T input)
Returns the proper
AttributeValue for the given enum type. |
T |
transformTo(AttributeValue input)
Returns the proper enum type for the given
AttributeValue input. |
EnhancedType<T> |
type()
Returns the
EnhancedType of the converter. |
public static <T extends Enum<T>> EnumAttributeConverter<T> create(Class<T> enumClass)
Enum.
Uses Enum::toString as the enum identifier.
T - the enum subclassenumClass - The enum class to be usedpublic static <T extends Enum<T>> EnumAttributeConverter<T> createWithNameAsKeys(Class<T> enumClass)
Enum.
Uses Enum::name as the enum identifier.
T - the enum subclassenumClass - The enum class to be usedpublic AttributeValue transformFrom(T input)
AttributeValue for the given enum type.transformFrom in interface AttributeConverter<T extends Enum<T>>input - the enum type to be convertedpublic T transformTo(AttributeValue input)
AttributeValue input.transformTo in interface AttributeConverter<T extends Enum<T>>input - the AttributeValue to be convertedpublic EnhancedType<T> type()
EnhancedType of the converter.type in interface AttributeConverter<T extends Enum<T>>public AttributeValueType attributeValueType()
AttributeValueType of the converter.attributeValueType in interface AttributeConverter<T extends Enum<T>>Copyright © 2023. All rights reserved.