I\'m using Amazon Web Services SDK for Java for DynamoDB; trying to suffice the interface for @DynamoDBMarshalling:
Class extends DynamoDBMarshaller<
The following worked fine to me:
The Marshaller:
public class EnumMarshaller implements DynamoDBMarshaller<Enum> {
@Override
public String marshall(Enum getterReturnResult) {
return getterReturnResult.name();
}
@Override
public Enum unmarshall(Class<Enum> clazz, String obj) {
return Enum.valueOf(clazz, obj);
}
}
In my table class with an enum:
@DynamoDBMarshalling(marshallerClass=EnumMarshaller.class)
@DynamoDBAttribute(attributeName = "MyEnum")
public MyEnum getMyEnum() {
return myEnum;
}
I worked around this problem by sub-classing the JsonMarshaller with a specific class type:
public class FooMarshaller extends JsonMarshaller<Foo>
{
// No impl required
}
Then the marshalling annotation is added to the data property like:
@DynamoDBMarshalling(marshallerClass = FooMarshaller.class)
public Set<Foo> getFoos()
{
return foos;
}
A pain if you have to add many class types, but it works.