Is it possible to get the class of the Enum from a variable of type EnumSet.
Consider the following code:
enum Foo
{
FOO_0,
FOO_1,
}
<E extends Enum<E>> void fooBar(EnumSet<E> enumSet, Class<E> type)
{
EnumSet<E> none = EnumSet.noneOf(type);
// ...
}
void bar()
{
EnumSet<Foo> enumSet = EnumSet.of(Foo.FOO_1);
fooBar(enumSet, Foo.class);
}
Writing Foo.class in fooBar() seems redundant. I would like to extract the class from the enumSet inside fooBar() function. Is that even possible?
What I wish to do is just call fooBar(enumSet); and still be able to instantiate the none variable as EnumSet.noneOf().