title: Java design issue: enum with underlying class
body: <p>I have an <code>enum</code> where each member is a <code>Set&lt;String&gt;</code>, i.e. the following is my code:</p>
  
  <pre><code>// Guava used only for the ease of "Sets&lt;E&gt;.newHashSet(E... elements)", no other
  // reason.
  // For pre-Java8 code, the toString() method needs to be changed.
  public enum MyEnum {
    MemberOne(Sets.newHashSet("this", "is", "the", "first", "member")),
    MemberTwo(Sets.newHashSet("this", "is", "the", "second", "member", "and", "it",
                              "has", "some", "more", "words"));
  
    private Set&lt;String&gt; elements;
  
    private MyEnum(Set&lt;String&gt; elements) { this.elements = elements; }
  
    public toString() {
      return elements.stream().collect(Collectors.joining(", "));
    }
  }
  </code></pre>
  
  <p>I have <code>MyEnum</code> because I want to have only a highly specific set of strings elsewhere in the project, where others should not be using a method with arbitrary <code>Set&lt;String&gt;</code>. But, I would also like to retain the functionalities of sets, i.e., I would like to be able to do something like</p>
  
  <pre><code>if (MyEnum.MemberOne.contains("some_random_word"))
    doSomethingSpecificToWordsInMemberOne();
  </code></pre>
  
  <p>Right now, I am thinking of adding a method <code>public Set&lt;String&gt; toSet() { return elements; }</code> to do this, mainly because <code>elements</code> should not be public.</p>
  
  <p>Is this a good way to design? Should I be doing something totally different? E.g.</p>
  
  <ul>
  <li>having a class with a bunch of <code>static final Set&lt;String&gt;</code> objects (my least favorite option)</li>
  <li>have <code>elements</code> as <code>public final</code> (my favorite option right now)</li>
  </ul>
  
  <p>My code has sets as enum members, but my doubt pertains to any situation where <code>Set&lt;String&gt;</code> is replaced with some other class.</p>