I have an EnumSet
and want to convert back-and-forth to/from an array of boolean primitives. If it works better, I could work with a List
instead of an array, and/or Boolean
objects rather than boolean primitives.
enum MyEnum { DOG, CAT, BIRD; }
EnumSet enumSet = EnumSet.of( MyEnum.DOG, MyEnum.CAT );
What I want to get on the other end is an array that looks like this:
[TRUE, TRUE, FALSE]
This Question here is similar to this one, Convert an EnumSet to an array of integers. Differences:
- boolean or
Boolean
versus integers (obviously) - I want all members of the enum to be represented, with a
TRUE
for each enum element included in theEnumSet
and aFALSE
for each element that is excluded from theEnumSet
. The other Question’s array includes only the items found in theEnumSet
. (more importantly)