Here you can find the source of fromString(Class
public static <T extends Enum<T>> T fromString(Class<T> clz, String value, T defaultVal)
//package com.java2s; // Licensed to the Apache Software Foundation (ASF) under one public class Main { public static <T extends Enum<T>> T fromString(Class<T> clz, String value, T defaultVal) { assert (clz != null); if (value != null) { try { return Enum.valueOf(clz, value.trim()); } catch (IllegalArgumentException ex) { assert (false); }/* ww w . ja va2 s . com*/ } return defaultVal; } public static <T extends Enum<T>> T fromString(Class<T> clz, String value) { assert (clz != null); if (value != null) { try { return Enum.valueOf(clz, value.trim()); } catch (IllegalArgumentException ex) { assert (false); } } return null; } }