(EnumSet set)
| 33 | @SuppressWarnings("serial") // we're overriding default serialization |
| 34 | final class ImmutableEnumSet<E extends Enum<E>> extends ImmutableSet<E> { |
| 35 | @SuppressWarnings("rawtypes") // necessary to compile against Java 8 |
| 36 | static ImmutableSet asImmutable(EnumSet set) { |
| 37 | switch (set.size()) { |
| 38 | case 0: |
| 39 | return ImmutableSet.of(); |
| 40 | case 1: |
| 41 | return ImmutableSet.of(Iterables.getOnlyElement(set)); |
| 42 | default: |
| 43 | return new ImmutableEnumSet(set); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /* |
| 48 | * Notes on EnumSet and <E extends Enum<E>>: |
no test coverage detected