title: How do you implement a Java Enumeration Abstract class and interface?
body: <p>I have the following problem.
  I have a package with different enumeration classes in java.</p>
  
  <p>What is the correct approach to avoid repeting myself when adding new methods that are common to all enums?</p>
  
  <p>My problem:</p>
  
  <p>channel.java</p>
  
  <pre><code>    public enum Channel {
             channel1, channel2;
      }
  </code></pre>
  
  <p>color.java</p>
  
  <pre><code>    public enum color{
             color1, color2;
      }
  </code></pre>
  
  <p>The method which should be used in both:</p>
  
  <pre><code>    public static boolean contains(String channel) {
         for (Channel c : Channel.values()) {
            if (c.name().equals(channel)) {
                return true;
            }
        }
      return false;
      }
  </code></pre>
  
  <p>Note that the loop has a reference to the enum itself. So, this will require copy and paste the method in all enums that I want to use it.
  Any suggestion?</p>
  
  <p>Thanks
  Victor</p>