Here you can find the source of valueOfIgnoreCase(Class
public static <T extends Enum<T>> T valueOfIgnoreCase(Class<T> enumType, String constantName)
//package com.java2s; /*--------------------------------------------------------------------------+ $Id: EnumUtils.java 16749 2008-06-20 16:04:47Z deissenb $ | | | Copyright 2005-2008 Technische Universitaet Muenchen | | | | Licensed under the Apache License, Version 2.0 (the "License"); | | you may not use this file except in compliance with the License. | | You may obtain a copy of the License at | | | | http://www.apache.org/licenses/LICENSE-2. | | | | Unless required by applicable law or agreed to in writing, software | | distributed under the License is distributed on an "AS IS" BASIS, | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | See the License for the specific language governing permissions and | | limitations under the License. | +--------------------------------------------------------------------------*/ public class Main { /**/*ww w . j a va 2s . co m*/ * Works like {@link #valueOf(Class, String)} but ignores case. * * Worst case runtime is O('number of constants in enum'). */ public static <T extends Enum<T>> T valueOfIgnoreCase(Class<T> enumType, String constantName) { T[] constants = enumType.getEnumConstants(); if (constants == null) { return null; } for (T constant : constants) { if (constant.name().equalsIgnoreCase(constantName)) { return constant; } } return null; } }