@ThreadSafe @Immutable public class OptionalAttributeConverter<T> extends Object implements AttributeConverter<Optional<T>>
Optional
and EnhancedAttributeValue
.Modifier and Type | Method and Description |
---|---|
AttributeValueType |
attributeValueType()
The
AttributeValueType that a converter stores and reads values
from DynamoDB via the AttributeValue class. |
static OptionalAttributeConverter |
create(AttributeConverter delegate) |
AttributeValue |
transformFrom(Optional<T> input)
Convert the provided Java object into an
AttributeValue . |
Optional<T> |
transformTo(AttributeValue input)
Convert the provided
AttributeValue into a Java object. |
EnhancedType<Optional<T>> |
type()
The type supported by this converter.
|
public static OptionalAttributeConverter create(AttributeConverter delegate)
public EnhancedType<Optional<T>> type()
AttributeConverter
type
in interface AttributeConverter<Optional<T>>
public AttributeValueType attributeValueType()
AttributeConverter
AttributeValueType
that a converter stores and reads values
from DynamoDB via the AttributeValue
class.attributeValueType
in interface AttributeConverter<Optional<T>>
public AttributeValue transformFrom(Optional<T> 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<Optional<T>>
public Optional<T> 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<Optional<T>>
Copyright © 2020. All rights reserved.