My class contains an initialized custom collection
class MyClass {
MyList<Integer> myList = MyList.create();
}
where MyList is a j.u.List. When deserializing, I get an exception saying that there is no known deserializer for MyList ("Cannot find a deserializer for non-concrete List type"), which is generally understandable, but I already initialized it, so there's no need for one. Instead, I just want to add the items to the list.
To demonstrate, I can add a private setter inside the class:
private void setMyList(List<Integer> ints) { ints.forEach(MyList::add); }
this works, but I don't think it should be needed. Specifically, Jackson should not create any list. It needs to deserialize the values of the items anyway; then instead of creating a list, add them to the existing one. It's a List, so it should know to call 'add' ('put' for map).
I know there is @JsonMerge, and I thought that that's what I needed, but just adding it to the field doesn't work, I still get the same exception. Am I not understanding @JsonMerge or am I doing something wrong?
Thanks!