Skip to content

Commit

Permalink
Fixes #272 EnumSet deserialization
Browse files Browse the repository at this point in the history
Signed-off-by: David Kral <david.k.kral@oracle.com>
  • Loading branch information
Verdent committed Jul 29, 2019
1 parent b6947aa commit c26c86c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ private T createInstance(DeserializerBuilder builder) {
if (rawType.isInterface()) {
final T x = createInterfaceInstance(rawType);
if (x != null) return x;
} else if (EnumSet.class.isAssignableFrom(rawType)) {
return (T) EnumSet.noneOf((Class<Enum>) collectionValueType);
}
return builder.getJsonbContext().getInstanceCreator().createInstance(rawType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public void testMarshallEnumSet() {

final String result = jsonb.toJson(languageEnumSet);
assertTrue("[\"Czech\",\"Slovak\"]".equals(result) || "[\"Slovak\",\"Czech\"]".equals(result));
assertEquals(languageEnumSet, jsonb.fromJson(result, new TestTypeToken<EnumSet<Language>>() {}.getType()));
}

@Test
Expand Down

0 comments on commit c26c86c

Please sign in to comment.