title: Subclassing an enum value
body: <p>I want to be able to subclass some values in an enum, in order that I don't have to repeat code too much. Is there some way I can do this? Here's an example of what I want to achieve, which Eclipse quickly tells me is an abomination:</p>
  
  <pre><code>public enum Foo {
      BAR {
          @Override
          public void taskA() {
              System.out.println("A");
          }
  
          @Override
          public void taskB() {}
      },
      BAZ extends BAR {
          @Override
          public void taskB() {
              System.out.println("B");
          }
      };
  
      public abstract void taskA();
      public abstract void taskB();
  }
  </code></pre>
  
  <p><code>BAR</code> would have only the implementation of <code>taskA</code> and an empty <code>taskB</code>, and <code>BAZ</code> would have both methods - <code>BAR</code>'s implementation of <code>taskA</code>, and its own implementation of <code>taskB</code>.</p>
  
  <p>I'm not changing the values of the enum after it's declared, so why doesn't this work? I could call <code>BAR</code>'s <code>taskA</code> method within <code>BAZ</code>, so why can't I do this?</p>