We are using the DynamoDB Enhanced Client from the latest Java AWS SDK to interact with our DynamoDB
@Builder(toBuilder = true)
@Setter
@NoArgsConstructor
@AllArgsConstructor
@DynamoDbBean
@ToString
@EqualsAndHashCode
public class ModificationsDAO {
@Getter(onMethod = @__({@DynamoDbPartitionKey, @DynamoDbAttribute("id")}))
private String id;
@Getter(onMethod = @__({@DynamoDbAttribute("values")}))
private GenericPair<?> values;
}
Where the GenericPair class looks like this –
class GenericPair<T> {
T oldValue;
T newValue;
Class< T > clazz;
} // Omitted getters, setters and constructors for brevity.
How do I serialize and deserialize this class while storing and reading from DynamoDB table?
I have gone through this Control Attribute Conversion documentation but not sure how to do this for this Generic type. Any help would be greatly appreciated.