title: How to extend enum class from abstract class?
body: <p>Having something like this:</p>
  
  <pre><code>public enum Token
  {
       FOO("foo", "f"),
       QUIT("quit", "q"),
       UNKNOWN("", "");
       ...
  
       public parse(String s) {
           for (Token token : values()) {
                ...
                return token;
           }
           return UNKNOWN;
       }
  }
  </code></pre>
  
  <p>An abstract class:</p>
  
  <pre><code>abstract class Base 
  {
      private boolean run;
  
      Base() {
          run = true;
  
          while (run) {
               inp = getInput();
               act(inp);
          }
      }
  
      public boolean act(String s) {
          boolean OK = true;
          switch (Token.parse(inp)) { /* Enum */
               case FOO:
                      do_foo();
                      break;
               case QUIT:
                      run = false;
                      break;
               case UNKNOWN:
                      print "Unknown" + inp;
                      OK = false;
                      break;
               }
           }
           return OK;
      }
  }
  </code></pre>
  
  <p>And the extender:</p>
  
  <pre><code>class Major extends Base
  {
  
  }
  </code></pre>
  
  <p>What I want is to extend <code>act</code> as in if <code>super</code> does not handle it then try to handle it in <code>Major</code>. E.g. add <code>PRINT_STAT("print-statistics", "ps")</code> - but at the same time let the <code>Base</code> class handle defaults like <code>QUIT</code>.</p>
  
  <p>Is this a completely wrong approach?</p>
  
  <p>What I have done so far is add an interface Typically:</p>
  
  <pre><code>public interface BaseFace
  {
        public boolean act_other(String inp);
  }
  </code></pre>
  
  <p>And in class <code>Base implements BaseFace</code>:</p>
  
  <pre><code>      case UNKNOWN:
            OK = act_other(inp);
  </code></pre>
  
  <p>And in class <code>Major</code>:</p>
  
  <pre><code>  public boolean act_other(String inp) { 
         if (inp.equals("blah")) {
              do_blah();
              return true; 
         }
         return false;
    }
  </code></pre>
  
  <p>Does this look like a usable design? </p>
  
  <p><strong>And, major question:</strong></p>
  
  <p>Is there some good way to extend the <code>Token</code> class such that I can use the same switch approach in <code>Major</code> as in <code>Base</code>? What I wonder is if there for one is a better design and second if I have to make a new Token class for <code>Major</code> or if I somehow can extend or otherwise re-use the existing.</p>
  
  <hr>
  
  <p>Edit: Point of concept is to have the <code>Base</code> class that I can easily re-use in different projects handling various types of input.</p>