Here you can find the source of valueOfOrNull(Class
public static <T extends Enum<T>> T valueOfOrNull(Class<T> enumType, String name)
//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) { if (name == null) return null; for (T enumValue : EnumSet.allOf(enumType)) { if (enumValue.toString().equals(name)) return enumValue; }//from w w w. j ava 2 s . com return null; } }