Here you can find the source of valueOfIgnoreCase(String text, Class
Parameter | Description |
---|---|
text | enum value name |
cls | enum class name |
public static <T extends Enum<T>> T valueOfIgnoreCase(String text, Class<T> cls)
//package com.java2s; //License from project: Open Source License import java.util.EnumSet; public class Main { /**//from w ww . j a va 2 s .c o m * find enum value ignoring case * * @param text enum value name * @param cls enum class name * @return enum found (null if not found) */ public static <T extends Enum<T>> T valueOfIgnoreCase(String text, Class<T> cls) { T result = null; for (T item : EnumSet.allOf(cls)) { if (item.name().equalsIgnoreCase(text)) { result = item; break; } } return result; } }