title: Using nested enum types in Java
body: <p>I have a data structure in mind that involves nested enums, such that I could do something like the following:</p>
  
  <pre><code>Drink.COFFEE.getGroupName();
  Drink.COFFEE.COLUMBIAN.getLabel();
  </code></pre>
  
  <p>And if there were method declarations:</p>
  
  <pre><code>someMethod(Drink type)
  someOtherMethod(DrinkTypeInterface type)
  </code></pre>
  
  <p>Then I could say (appropriately):</p>
  
  <pre><code>someMethod(Drink.COFFEE)
  someOtherMethod(Drink.COFFEE.COLUMBIAN)
  </code></pre>
  
  <p>This is what I came up with:</p>
  
  <pre><code>public enum Drink {
  
      COFFEE("Coffee");
  
      private String groupName;
  
      private Drink(String groupName) {
          this.groupName = groupName;
      }
  
      public enum Coffee implements DrinkTypeInterface {
  
          COLUMBIAN("Columbian Blend"),
          ETHIOPIAN("Ethiopian Blend");
  
          private String label;
  
          private Coffee(String label) {
              this.label = label;
          }
  
          public String getLabel() {
              return this.label;
          }
      }
  
      String getGroupName() {
          return this.groupName;
      }
  }
  </code></pre>
  
  <p>And the interface:</p>
  
  <pre><code>public interface DrinkTypeInterface {
  
      public String getLabel();
  }
  </code></pre>
  
  <p>I think I'm just trying to wrap my head around what the best way to do this sort of thing is in Java, or if I need to write a bunch of if-statements to deal with the individual Drink.values().  Any help?</p>