I read here a nice example about using ImmutableSet
from Guava. The example is reported here for the sake of completeness:
public static final ImmutableSet<String> COLOR_NAMES = ImmutableSet.of(
"red",
"orange",
"yellow",
"green",
"blue",
"purple");
class Foo {
Set<Bar> bars;
Foo(Set<Bar> bars) {
this.bars = ImmutableSet.copyOf(bars); // defensive copy!
}
}
The question is, can I obtain the same result by using a Java enum?
PS: This question added into my mind more chaos!