@ThreadSafe @Immutable public final class OptionalDoubleAttributeConverter extends Object implements AttributeConverter<OptionalDouble>
OptionalDouble and AttributeValue.
This stores values in DynamoDB as a number.
This supports converting numbers stored in DynamoDB into a double-precision floating point number, within the range
Double.MIN_VALUE, Double.MAX_VALUE. Null values are converted to OptionalDouble.empty(). For less
precision or smaller values, consider using OptionalAttributeConverter along with a Float type.
For greater precision or larger values, consider using OptionalAttributeConverter along with a
BigDecimal type.
If values are known to be whole numbers, it is recommended to use a perfect-precision whole number representation like those
provided by OptionalIntAttributeConverter, OptionalLongAttributeConverter, or a
OptionalAttributeConverter along with a BigInteger type.
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 OptionalDoubleAttributeConverter |
create() |
AttributeValue |
transformFrom(OptionalDouble input)
Convert the provided Java object into an
AttributeValue. |
OptionalDouble |
transformTo(AttributeValue input)
Convert the provided
AttributeValue into a Java object. |
EnhancedType<OptionalDouble> |
type()
The type supported by this converter.
|
public static OptionalDoubleAttributeConverter create()
public EnhancedType<OptionalDouble> type()
AttributeConvertertype in interface AttributeConverter<OptionalDouble>public AttributeValueType attributeValueType()
AttributeConverterAttributeValueType that a converter stores and reads values
from DynamoDB via the AttributeValue class.attributeValueType in interface AttributeConverter<OptionalDouble>public AttributeValue transformFrom(OptionalDouble input)
AttributeConverterAttributeValue. 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<OptionalDouble>public OptionalDouble transformTo(AttributeValue input)
AttributeConverterAttributeValue 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<OptionalDouble>Copyright © 2023. All rights reserved.