public static <T extends Enum<T>>T forKey(int key,Map<Integer,T> mapping,Class<T> enumeration){
  T t=mapping.get(key);
  if (t != null) {
    return t;
  }
  throw new IllegalArgumentException("Not an alternate key for " + enumeration.toString() + ": "+ key);
}

public static < T extends Enum < T > > T forKey ( int key , Map < Integer , T > mapping , Class < T > enumeration ) { T t = mapping . get ( key ) ; if ( t != null ) { return t ; } throw new IllegalArgumentException ( "Not an alternate key for " + enumeration . toString ( ) + ": " + key ) ; }
boilerplate method to retrieve an enum method via an arbitrary key , rather than just the enum value .
