@Inherited @Retention(value=RUNTIME) @Target(value={TYPE,FIELD,METHOD,ANNOTATION_TYPE}) public @interface DynamoDBTyped
@DynamoDBTyped(DynamoDBAttributeType.S) public MyObject getMyObject()
Standard Types
Standard types do not require the annotation if applying the default attribute binding for that type.
String/S
types,
Number/N
types,
BigDecimal
BigInteger
Boolean
/boolean
Byte
/byte
Double
/double
Float
/float
Integer
/int
Long
/long
Short
/short
Binary/B
types,
ByteBuffer
byte[]
A custom type-converter maybe applied to any attribute, either by annotation or by overriding the standard type-converter factory.
DynamoDBMapperConfig config = DynamoDBMapperConfig.builder() .withTypeConverterFactory(DynamoDBTypeConverterFactory.standard().override() .with(String.class, MyObject.class, new StringToMyObjectConverter()) .build()) .build();
If the converter being applied is already a supported data type and
the conversion is of the same attribute type, for instance,
Date
to String
to S
,
the annotation may be omited. The annotation is require for all non-standard
types or if the attribute type binding is being overriden.
Direct native conversion is supported by default in all schemas.
If the attribute is a primary or index key, it must specify either
B
, N
, or S
, otherwise, it may be omited.
Boolean
to BOOL
The standard V2 conversion schema will by default serialize booleans
natively using the DynamoDB BOOL
type.
@DynamoDBTyped(DynamoDBAttributeType.BOOL) public boolean isTesting()
Boolean
to N
The standard V1 and V2 compatible conversion schemas will by default
serialize booleans using the DynamoDB N
type, with a value of '1'
representing 'true' and a value of '0' representing 'false'.
@DynamoDBTyped(DynamoDBAttributeType.N) public boolean isTesting()
Enum
to S
The enum
type is only supported by override or custom converter.
There are some risks in distributed systems when using enumerations as
attributes intead of simply using a String. When adding new values to the
enumeration, the enum only changes must deployed before the enumeration
value can be persisted. This will ensure that all systems have the correct
code to map it from the item record in DynamoDB to your objects.
public enum Status { OPEN, PENDING, CLOSED }; @DynamoDBTyped(DynamoDBAttributeType.S) public Status getStatus()
UUID
to B
The UUID
type will serialize to String
/S
by
default in all conversion schemas. The schemas do support serializing to
ByteBuffer
/B
by override.
@DynamoDBTyped(DynamoDBAttributeType.B) public UUID getKey()
Set
to L
The standard V1 and V2 compatible conversion schemas do not by default
support non-scalar Set
types. They are supported in V2. In
non-supported schemas, the List
/L
override may be applied
to any Set
type.
@DynamoDBTyped(DynamoDBAttributeType.L) public Set<MyObject> getMyObjects()
Object
to M
Also supported as DynamoDBDocument
.
@DynamoDBTyped(DynamoDBAttributeType.M) public MyObject getMyObject()
May be combined with DynamoDBTypeConverted
.
May be used as a meta-annotation.
Modifier and Type | Optional Element and Description |
---|---|
DynamoDBMapperFieldModel.DynamoDBAttributeType |
value
Use when the type of the attribute as stored in DynamoDB should differ
from the standard type assigned by DynamoDBMapper.
|
public abstract DynamoDBMapperFieldModel.DynamoDBAttributeType value
Copyright © 2013 Amazon Web Services, Inc. All Rights Reserved.