title: Enum static Method being called from Generic class
body: <p>I want to make a refactoring and want to create a generic class for avoiding duplicate code. We have many XXXCriteriaValidator in our project and we want to make one only unique class to substitute them all.</p>
  
  <p>The problem is one line where this class calls for a static method from an Enum. Here you will see. This is more or less what I'mtrying to achieve:</p>
  
  <pre><code>public class GenericCriteriaValidator&lt;T extends ¿SomeKindOfEnumInterface?&gt; 
                                                 implements CriterionVisitor {
  
      protected Errors errors;
  
      public Errors getErrors() {
          return this.errors;
      }
  
      /* 
       * Some code around here 
       */
  
      protected void doVisit(final PropertyCriterion criterion) {
          if (criterion == null) {
              this.errors.reject("error.criterion.null");
          } else {
              if (criterion.getOperator() == null) {
                  this.errors.reject("error.operator.null");
              }
  
              // Validates property (exception thrown if not exists)
              T.fromString(criterion.getName()); // The problem is this call here!!
                                                 // Not saying this compiles, just looking
                                                 // how to do something equivalent
          }
      }
  }
  </code></pre>
  
  <p>T is always a differente Enum. The typical enum is like this:</p>
  
  <pre><code>public enum ContactCriteria implements CriteriaInterface&lt;ContactCriteria&gt;  {
                                         // ^ This interface is added by me
                                         //   for the enum being called in the previous                           class
  
      CONTACT_ID("this.id"),
      CONTACT_COMPANY_ID("this.companyId"),
      CONTACT_NAME("this.name"),
      CONTACT_EMAIL("this.email"),
      CONTACT_PHONE_NUMBER("this.phoneNumber"),
      CONTACT_ORDER("this.order"),
  
      private final String alias;
  
      ContactCriteria(final String alias) {
          this.alias = alias;
      }
  
      public String getAlias() {
          return this.alias;
      }
  
      public static ContactCriteria fromString(final String name) {
          ContactCriteria result = null;
  
          if (name != null) {
              result = Enum.valueOf(ContactCriteria.class, name);
          }
          return result;
      }
  
      public ContactCriteria returnThis() {
          return this;
      }
  
  }
  </code></pre>
  
  <p>Finally, I'm looking for making an interface for the first class to accept the fromString method of T. I suppose it should be similar to:</p>
  
  <pre><code>public interface CriteriaInterface&lt;T&gt; {
      static T fromString(String name);
      // ^ This static is important
  }
  </code></pre>
  
  <p>I haven't found none post or strategy for making something similar with an Enum. I know the Enum can implement an interface, but don't know how to get it.</p>
  
  <p>Please help. Thanks in advance</p>