Export to GitHub

kryo - issue #91

Allow EnumSetSerializer to work with empty EnumSets


Posted on Sep 25, 2012 by Helpful Cat

I was rather surprised by the original error, so I made a minor revision to allow the class of the contained Enum to be determined. As long as the Enum has at least one definition, using the complement of an empty set works.

EnumSet.allOf(Enum) == EnumSet.complementOf(EnumSet.noneOf(Enum))

Unfortunately, I could not get the EnumMap to behave in a similar fashion due to the constructor requiring a class object and EnumSet.copyOf(Collection) doesn't work if the collection is empty :(

I hate Java generics...

Attachments

Comment #1

Posted on Oct 2, 2013 by Swift Horse

Fixed in r414. A dedicated JUnit test was added.

Status: Fixed

Labels:
Type-Patch