@ThreadSafe @Immutable public final class MonthDayAttributeConverter extends Object implements AttributeConverter<MonthDay>
MonthDay
and AttributeValue
.
This stores and reads values in DynamoDB as a number, so that they can be sorted numerically as part of a sort key.
LocalTimes are stored in the format "MMDD", where:
Examples:
MonthDay.of(5, 21)
is stored as ItemAttributeValueMapper.fromNumber("0521")
MonthDay.of(12, 1)
is stored as ItemAttributeValueMapper.fromNumber("1201")
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 MonthDayAttributeConverter |
create() |
AttributeValue |
transformFrom(MonthDay input)
Convert the provided Java object into an
AttributeValue . |
MonthDay |
transformTo(AttributeValue input)
Convert the provided
AttributeValue into a Java object. |
EnhancedType<MonthDay> |
type()
The type supported by this converter.
|
public static MonthDayAttributeConverter create()
public EnhancedType<MonthDay> type()
AttributeConverter
type
in interface AttributeConverter<MonthDay>
public AttributeValueType attributeValueType()
AttributeConverter
AttributeValueType
that a converter stores and reads values
from DynamoDB via the AttributeValue
class.attributeValueType
in interface AttributeConverter<MonthDay>
public AttributeValue transformFrom(MonthDay input)
AttributeConverter
AttributeValue
. This will raise a RuntimeException
if the
conversion fails, or the input is null.
Example:
InstantAsStringAttributeConverter converter = InstantAsStringAttributeConverter.create();
assertEquals(converter.toAttributeValue(Instant.EPOCH),
ItemAttributeValue.fromString("1970-01-01T00:00:00Z"));
transformFrom
in interface AttributeConverter<MonthDay>
public MonthDay 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.fromAttributeValue(ItemAttributeValue.fromString("1970-01-01T00:00:00Z")),
Instant.EPOCH);
transformTo
in interface AttributeConverter<MonthDay>
Copyright © 2020. All rights reserved.