Interface AttributeConverter<T>
- All Known Implementing Classes:
AtomicBooleanAttributeConverter
,AtomicIntegerAttributeConverter
,AtomicLongAttributeConverter
,BigDecimalAttributeConverter
,BigIntegerAttributeConverter
,BooleanAttributeConverter
,ByteArrayAttributeConverter
,ByteAttributeConverter
,ByteBufferAttributeConverter
,CharacterArrayAttributeConverter
,CharacterAttributeConverter
,CharSequenceAttributeConverter
,DocumentAttributeConverter
,DoubleAttributeConverter
,DurationAttributeConverter
,EnumAttributeConverter
,FloatAttributeConverter
,InstantAsStringAttributeConverter
,IntegerAttributeConverter
,JsonItemAttributeConverter
,ListAttributeConverter
,LocalDateAttributeConverter
,LocalDateTimeAttributeConverter
,LocaleAttributeConverter
,LocalTimeAttributeConverter
,LongAttributeConverter
,MapAttributeConverter
,MonthDayAttributeConverter
,OffsetDateTimeAsStringAttributeConverter
,OptionalAttributeConverter
,OptionalDoubleAttributeConverter
,OptionalIntAttributeConverter
,OptionalLongAttributeConverter
,PeriodAttributeConverter
,SdkBytesAttributeConverter
,SdkNumberAttributeConverter
,SetAttributeConverter
,ShortAttributeConverter
,StringAttributeConverter
,StringBufferAttributeConverter
,StringBuilderAttributeConverter
,UriAttributeConverter
,UrlAttributeConverter
,UuidAttributeConverter
,ZonedDateTimeAsStringAttributeConverter
,ZoneIdAttributeConverter
,ZoneOffsetAttributeConverter
Converts between a specific Java type and an
AttributeValue
.
Examples:
- The
StringAttributeConverter
converts aString
into a DynamoDB string (AttributeValue.s()
). - The
InstantAsStringAttributeConverter
converts anInstant
into a DynamoDB string (AttributeValue.s()
).
-
Method Summary
Modifier and TypeMethodDescriptionTheAttributeValueType
that a converter stores and reads values from DynamoDB via theAttributeValue
class.transformFrom
(T input) Convert the provided Java object into anAttributeValue
.transformTo
(AttributeValue input) Convert the providedAttributeValue
into a Java object.type()
The type supported by this converter.
-
Method Details
-
transformFrom
Convert the provided Java object into anAttributeValue
. This will raise aRuntimeException
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());
-
transformTo
Convert the providedAttributeValue
into a Java object. This will raise aRuntimeException
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);
-
type
EnhancedType<T> type()The type supported by this converter. -
attributeValueType
AttributeValueType attributeValueType()TheAttributeValueType
that a converter stores and reads values from DynamoDB via theAttributeValue
class.
-