public static <T extends Enum<T>> T random(Class<T> enumClass) {
    EnumSet<T> enums = EnumSet.allOf(enumClass);
    return IterableUtils.randomFrom(enums);
  }
public static < T extends Enum < T > > T random ( Class < T > enumClass ) { EnumSet < T > enums = EnumSet . allOf ( enumClass ) ; return IterableUtils . randomFrom ( enums ) ; }
Returns a random element from the given enum class.

@param enumClass enum class to return random element from
@param <T> the type of the given enum class
@return random element from the given enum class
@throws IllegalArgumentException if the given enumClass has no values