@ThreadSafe public interface AttributeConverter<T>
AttributeValue.
Examples:
StringAttributeConverter converts a String into a DynamoDB string
(AttributeValue.s()).InstantAsStringAttributeConverter converts an Instant into a DynamoDB string
(AttributeValue.s()).| Modifier and Type | Method and Description |
|---|---|
AttributeValueType |
attributeValueType()
The
AttributeValueType that a converter stores and reads values
from DynamoDB via the AttributeValue class. |
AttributeValue |
transformFrom(T input)
Convert the provided Java object into an
AttributeValue. |
T |
transformTo(AttributeValue input)
Convert the provided
AttributeValue into a Java object. |
EnhancedType<T> |
type()
The type supported by this converter.
|
AttributeValue transformFrom(T input)
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());
T transformTo(AttributeValue input)
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);
EnhancedType<T> type()
AttributeValueType attributeValueType()
AttributeValueType that a converter stores and reads values
from DynamoDB via the AttributeValue class.Copyright © 2020. All rights reserved.