Reputation: 37
In Dynamo, is it safe/proper practice to alter the contents of the annotated set and get methods of a pojo mapper class to perform some marshaling tasks?
e.g.
@DynamoDBAttribute(attributeName = "BookInfo")
public String[] getBookInfo(){
return new String[]{this.title, this.author}
}
public void setBookInfo(String[] info){
this.title = info[0];
this.author = info[1];
}
where title and author are not attributes but fields in the class
Note: I understand the above example is a poor use of Dynamo and the title and author should be just separate fields, but it is just a quick example.
Upvotes: 1
Views: 59
Reputation: 5205
The Mapper uses reflection/introspection to determine what fields to map to attribute values in a DynamoDB item. As such the only thing that matters to the Mapper is the signature of the set/getBookInfo methods you annotate. What you do with the values passed in and out of these methods is your implementation detail. If the Mapper supports the data type in the signature, then the Mapper will be able to interpret that AttributeValue in the items.
Upvotes: 1