Java EnumSet Usage valueOfOrNull(Class enumType, String name)

Here you can find the source of valueOfOrNull(Class enumType, String name)

Description

value Of Or Null

License

Open Source License

Declaration

public static <T extends Enum<T>> T valueOfOrNull(Class<T> enumType, String name) 

Method Source Code


//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;
    }
}

Related

  1. nextEnum(T ce)
  2. possibilities(Class enumClass)
  3. rotateEnum(T ce, boolean backwards, EnumSet ValidOptions)
  4. setOnly(EnumSet theSet, E flag)
  5. valueOfIgnoreCase(String text, Class cls)
  6. valueOfOrNull(Class enumType, String name, boolean checkCase)