I have a class with a SequencedSet
field, but I can't find a way to make it work with jackson deserialization.
class MyClass {
private SequencedSet<UUID> ids;
public SequencedSet<UUID> getIds() {
return ids;
}
public void setIds(SequencedSet<UUID> ids) {
this.ids = ids;
}
}
I get this error
InvalidDefinition Cannot find a deserializer for non-concrete Collection type [collection type; class java.util.SequencedSet, contains [simple type, class java.util.UUID]]
Edit: I defaulted to using LinkedHashSet instead of SequencedSet
As a workaround I made just the setter using
LinkedHashSet
. Then at least the field and the getter may useSequencedSet
.This requires (de)serialization via getters/setters (or constructors) instead of direct field access though.
To the question in the comments which implementation I expected:
LinkedHashSet
or similar because that preserves the properties of aSequencedSet
: The order is preserved and no duplicates are allowed. ForSet
andList
Jackson automatically selects concrete implementations too.