Is there a clean way to map Optional fields with DynamoDBMapper, for both basic types and arbitrary/custom objects?
I believe one option would be to implement DynamoDBTypeConverter for optionals of basic types (Optional<String>
, Optional<Integer>
, etc). But, in addition to being a bit dirty, this would not work for custom objects.
I am looking for some sort of "chaining" behaviour of converters, where the default converter is applied first and the result wrapped in case of optional fields.
Is there a way to specify this behaviour?
@DynamoDBTable
public class MyModel {
@DynamoDBAttribute
private Optional<String> someStringField;
@DynamoDBAttribute
private Optional<AnotherModel> someAnotherModelField;
...
}
@DynamoDBDocument
public class AnotherModel {
}