whueric / kryo

Automatically exported from code.google.com/p/kryo
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Allow EnumSetSerializer to work with empty EnumSets #91

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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...

Original issue reported on code.google.com by Devin.Ch...@gmail.com on 25 Sep 2012 at 11:52

Attachments:

GoogleCodeExporter commented 8 years ago
Fixed in r414. A dedicated JUnit test was added.

Original comment by romixlev on 2 Oct 2013 at 8:14