Is there an easy way to serialize and deserialize enum sets with Jackson?
private enum Type {
YES, NO
}
@JacksonXmlProperty(localName = "type", isAttribute = true)
private final EnumSet<Type> types;
This gives the following XML:
...<type type="YES" type="NO"/>...
This XML is not valid, since there is a duplicate attribute.
I tried also the following annotations:
@JsonSerialize(using = EnumSetSerializer.class)
@JacksonXmlProperty(localName = "type", isAttribute = true)
private final EnumSet<Type> mTypes;
But this gives the following error:
Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: Class com.fasterxml.jackson.databind.ser.std.EnumSetSerializer has no default (no arg) constructor