Here you can find the source of fromString(Class
public static <T extends Enum<T>> T fromString(Class<T> enumType, String text)
//package com.java2s; //License from project: Open Source License public class Main { public static <T extends Enum<T>> T fromString(Class<T> enumType, String text) { if (text != null) { for (T value : enumType.getEnumConstants()) { if (text.equalsIgnoreCase(value.toString())) { return value; }//from w ww . ja va 2 s . co m } } throw new IllegalArgumentException("No constant with text " + text + " found"); } }