Carlos Bribiescas Carlos Bribiescas - 4 years ago 223
Java Question

Immutable version of EnumSet

I can't find an Immutable version of EnumSet. Two questions:

Can I use Enums in a normal Guava ImmutableSet?

If I can, what are some benefits/drawbacks of using an ImmutableSet instead of the EnumSet?

Answer Source

Are you looking for Sets.immutableEnumSet perhaps?

Returns an immutable set instance containing the given enum elements. Internally, the returned set will be backed by an EnumSet.

The iteration order of the returned set follows the enum's iteration order, not the order in which the elements appear in the given collection.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download