Here you can find the source of valueOfOrNull(Class
public static <T extends Enum<T>> T valueOfOrNull(Class<T> enumType, String name, boolean checkCase)
//package com.java2s; //License from project: Open Source License import java.util.EnumSet; public class Main { public static <T extends Enum<T>> T valueOfOrNull(Class<T> enumType, String name, boolean checkCase) { if (name == null) { return null; }//from w ww .j a va 2 s . com for (T enumValue : EnumSet.allOf(enumType)) { if (checkCase) { if (enumValue.toString().equals(name)) { return enumValue; } } else { if (enumValue.toString().equalsIgnoreCase(name)) { return enumValue; } } } return null; } }