@Retention(value=RUNTIME) @Target(value={TYPE,FIELD,METHOD}) public @interface DynamoDBTypeConvertedJson
@DynamoDBTable(tableName="TestTable") public class TestClass { private String key; private Currency currency; @DynamoDBHashKey public String getKey() { return key; } public void setKey(String key) { this.key = key; } @DynamoDBTypeConvertedJson public Currency getCurrency() { return currency; } public void setCurrency(Currency currency) { this.currency = currency; } }With the following complex type to convert,
public class Currency { private Double amount; private String unit; public Double getAmount() { return amount; } public void setAmount(Double amount) { this.amount = amount; } public String getUnit() { return unit; } public void setUnit(String unit) { this.unit = unit; } }Would write the following value to DynamoDB given,
Currency(79.99,"USD")
= "{\"amount\":79.99,\"unit\":\"USD\"}"
DynamoDBTypeConverted
Modifier and Type | Optional Element and Description |
---|---|
Class<? extends Object> |
targetType
The value type to use when calling the JSON mapper's
readValue ;
a value of Void.class indicates to use the getter's type. |
Copyright © 2016. All rights reserved.