@ThreadSafe @Immutable public final class LocaleAttributeConverter extends Object implements AttributeConverter<Locale>
Locale
and AttributeValue
.
This stores and reads values in DynamoDB as a string, according to the format of
Locale.forLanguageTag(String)
and Locale.toLanguageTag()
.
Modifier and Type | Field and Description |
---|---|
static LocaleStringConverter |
STRING_CONVERTER |
Constructor and Description |
---|
LocaleAttributeConverter() |
Modifier and Type | Method and Description |
---|---|
AttributeValueType |
attributeValueType()
The
AttributeValueType that a converter stores and reads values
from DynamoDB via the AttributeValue class. |
static LocaleAttributeConverter |
create() |
AttributeValue |
transformFrom(Locale input)
Convert the provided Java object into an
AttributeValue . |
Locale |
transformTo(AttributeValue input)
Convert the provided
AttributeValue into a Java object. |
EnhancedType<Locale> |
type()
The type supported by this converter.
|
public static final LocaleStringConverter STRING_CONVERTER
public static LocaleAttributeConverter create()
public EnhancedType<Locale> type()
AttributeConverter
type
in interface AttributeConverter<Locale>
public AttributeValueType attributeValueType()
AttributeConverter
AttributeValueType
that a converter stores and reads values
from DynamoDB via the AttributeValue
class.attributeValueType
in interface AttributeConverter<Locale>
public AttributeValue transformFrom(Locale input)
AttributeConverter
AttributeValue
. This will raise a RuntimeException
if the
conversion fails, or the input is null.
Example:
InstantAsStringAttributeConverter converter = InstantAsStringAttributeConverter.create();
assertEquals(converter.transformFrom(Instant.EPOCH),
EnhancedAttributeValue.fromString("1970-01-01T00:00:00Z").toAttributeValue());
transformFrom
in interface AttributeConverter<Locale>
public Locale transformTo(AttributeValue input)
AttributeConverter
AttributeValue
into a Java object. This will raise a RuntimeException
if the
conversion fails, or the input is null.
Example:
InstantAsStringAttributeConverter converter = InstantAsStringAttributeConverter.create();
assertEquals(converter.transformTo(EnhancedAttributeValue.fromString("1970-01-01T00:00:00Z").toAttributeValue()),
Instant.EPOCH);
transformTo
in interface AttributeConverter<Locale>
Copyright © 2023. All rights reserved.