@ThreadSafe @Immutable public final class PeriodAttributeConverter extends Object implements AttributeConverter<Period>
Period
and AttributeValue
.
This stores and reads values in DynamoDB as a string, according to the format of Period.parse(CharSequence)
and
Period.toString()
.
This can be created via create()
.
Modifier and Type | Method and Description |
---|---|
AttributeValueType |
attributeValueType()
The
AttributeValueType that a converter stores and reads values
from DynamoDB via the AttributeValue class. |
static PeriodAttributeConverter |
create() |
AttributeValue |
transformFrom(Period input)
Convert the provided Java object into an
AttributeValue . |
Period |
transformTo(AttributeValue input)
Convert the provided
AttributeValue into a Java object. |
EnhancedType<Period> |
type()
The type supported by this converter.
|
public static PeriodAttributeConverter create()
public EnhancedType<Period> type()
AttributeConverter
type
in interface AttributeConverter<Period>
public AttributeValueType attributeValueType()
AttributeConverter
AttributeValueType
that a converter stores and reads values
from DynamoDB via the AttributeValue
class.attributeValueType
in interface AttributeConverter<Period>
public AttributeValue transformFrom(Period 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<Period>
public Period 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<Period>
Copyright © 2021. All rights reserved.