Java Class Load fromString(Class enumType, String text)

Here you can find the source of fromString(Class enumType, String text)

Description

from String

License

Open Source License

Declaration

public static <T extends Enum<T>> T fromString(Class<T> enumType, String text) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static <T extends Enum<T>> T fromString(Class<T> enumType, String text) {
        if (text != null) {
            for (T value : enumType.getEnumConstants()) {
                if (text.equalsIgnoreCase(value.toString())) {
                    return value;
                }//from   w  ww . ja  va 2 s  .  co  m
            }
        }
        throw new IllegalArgumentException("No constant with text " + text + " found");
    }
}

Related

  1. classForNameOrPrimitive(String name, ClassLoader loader)
  2. fromString(Class clazz, String stringValue)
  3. fromString(Class clazz, String name)
  4. fromString(Class clz, String value, T defaultVal)
  5. fromString(Class enumClass, String s, T defaultValue)
  6. fromString(final Class clazz, final String value)
  7. fromString(String string, Class arrayClass)
  8. getClass(Class clazz)
  9. getClass(String className)