@ThreadSafe @Immutable public final class FloatAttributeConverter extends Object implements AttributeConverter<Float>, PrimitiveConverter<Float>
Float and AttributeValue.
This stores values in DynamoDB as a number.
This supports converting numbers stored in DynamoDB into a single-precision floating point number, within the range
Float.MIN_VALUE, Float.MAX_VALUE. For more precision or larger values, consider using
DoubleAttributeConverter or BigDecimalAttributeConverter.
If values are known to be whole numbers, it is recommended to use a perfect-precision whole number representation like those
provided by ShortAttributeConverter, IntegerAttributeConverter or BigIntegerAttributeConverter.
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 FloatAttributeConverter |
create() |
EnhancedType<Float> |
primitiveType()
The type supported by this converter.
|
AttributeValue |
transformFrom(Float input)
Convert the provided Java object into an
AttributeValue. |
Float |
transformTo(AttributeValue input)
Convert the provided
AttributeValue into a Java object. |
EnhancedType<Float> |
type()
The type supported by this converter.
|
public static FloatAttributeConverter create()
public EnhancedType<Float> type()
AttributeConvertertype in interface AttributeConverter<Float>public AttributeValueType attributeValueType()
AttributeConverterAttributeValueType that a converter stores and reads values
from DynamoDB via the AttributeValue class.attributeValueType in interface AttributeConverter<Float>public AttributeValue transformFrom(Float 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<Float>public Float 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<Float>public EnhancedType<Float> primitiveType()
PrimitiveConverterprimitiveType in interface PrimitiveConverter<Float>Copyright © 2023. All rights reserved.