@Retention(value=RUNTIME) @Target(value={TYPE,FIELD,METHOD}) public @interface DynamoDBDelimited
String
attribute.
A minimal example using getter annotations,
@DynamoDBTable(tableName="TestTable") public class TestClass { private String key; private PhoneNumber phoneNumber; @DynamoDBHashKey public String getKey() { return key; } public void setKey(String key) { this.key = key; } @DynamoDBDelimited(attributeNames={"areaCode","exchange","subscriber"}, delimiter='-') public PhoneNumber getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(PhoneNumber phoneNumber) { this.phoneNumber = phoneNumber; } }With the following complex type to string delimit,
public class PhoneNumber { private String areaCode; private String exchange; private String subscriber; public String getAreaCode() { return areaCode; } public void setAreaCode(String areaCode) { this.areaCode = areaCode; } public String getExchange() { return exchange; } public void setExchange(String exchange) { this.exchange = exchange; } public String getSubscriber() { return subscriber; } public void setSubscriber(String subscriber) { this.subscriber = subscriber; } }Would write the following value to DynamoDB given,
PhoneNumber("206","266","1000")
= "206-266-1000"
PhoneNumber("206",null,"1000")
= "206--1000"
PhoneNumber("206",null,null)
= "206--"
PhoneNumber(null,"266","1000")
= "-266-1000"
PhoneNumber(null,"266",null)
= "-266-"
PhoneNumber(null,null,"1000")
= "--1000"
PhoneNumber(null,null,null)
= null
null
= null
""
= empty string not allowed by DDB but would produce empty object
"--"
= PhoneNumber(null,null,null)
"-----"
= PhoneNumber(null,null,null)
"206"
= PhoneNumber("206",null,null)
"206-266"
= PhoneNumber("206","266",null)
"206-266-1000-1234-5678"
= PhoneNumber("206","266","1000")
DynamoDBTypeConverter
.
New delimited values may always be appended to the string, however, there
are some risks in distributed systems where, if one system has updated
delimiting instructions and begins to persist new values, other systems,
which also persist that same data, would effectively truncate it back to the
original format.
Auto-generated annotations are not supported on field/property. However,
conversion annotations such as DynamoDBTypeConvertedTimestamp
and
DynamoDBTypeConverted
where the output type is String
are
supported.Modifier and Type | Required Element and Description |
---|---|
String[] |
attributeNames
The ordered list of attribute/field names.
|
Modifier and Type | Optional Element and Description |
---|---|
char |
delimiter
The delimiter for separating attribute values; default is
| . |
public abstract String[] attributeNames
Copyright © 2016. All rights reserved.