What happened?
Union values that are sets have a few quirks. eg:
MyUnion:
union:
fooSet: set<Foo>
They are not implemented as LinkedHashSet, and so do not retain insertion order like conjure'd set<> fields do.
They are not immutable copies (!).
They are slightly more difficult to construct (eg MyUnion.fooSet(...) the arg must be a set).
The generated FooSetWrapper:
@JsonTypeName("fooSet")
private static final class FooSetWrapper implements Base {
private final Set<Foo> value;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
private FooSetWrapper(@JsonSetter(value = "fooSet", nulls = Nulls.AS_EMPTY) @Nonnull Set<Foo> value) {
Preconditions.checkNotNull(value, "fooSet cannot be null");
this.value = value;
}
// ...
Regular conjure objects are deserialized via their builder, which initializes sets as LinkedHashSet, copies the incoming value, and then on build stores an immutable set.
I would guess this behavior extends to Maps as union members also.
What did you want to happen?
- Maintain insertion order like conjure fields. Probably this arg needs a
@JsonDeserialize(as = LinkedHashSet.class).
- Do not store this.value directly, make a copy.
- Have additional Union creators that take Iterable like regular fields.
What happened?
Union values that are sets have a few quirks. eg:
They are not implemented as LinkedHashSet, and so do not retain insertion order like conjure'd
set<>fields do.They are not immutable copies (!).
They are slightly more difficult to construct (eg
MyUnion.fooSet(...)the arg must be a set).The generated
FooSetWrapper:Regular conjure objects are deserialized via their builder, which initializes sets as
LinkedHashSet, copies the incoming value, and then on build stores an immutable set.I would guess this behavior extends to Maps as union members also.
What did you want to happen?
@JsonDeserialize(as = LinkedHashSet.class).