Java EnumSet Usage findEnumIgnoreCase(Class enumClass, String string, T defValue)

Here you can find the source of findEnumIgnoreCase(Class enumClass, String string, T defValue)

Description

find Enum Ignore Case

License

MIT License

Declaration

public static <T extends Enum<T>> T findEnumIgnoreCase(Class<T> enumClass, String string, T defValue) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright ? 2012-2015 eBay Software Foundation
 *  This program is dual licensed under the MIT and Apache 2.0 licenses.
 *  Please see LICENSE for more information.
 *******************************************************************************/

import java.util.EnumSet;

public class Main {
    public static <T extends Enum<T>> T findEnumIgnoreCase(Class<T> enumClass, String string, T defValue) {
        for (T value : EnumSet.allOf(enumClass))
            if (value.toString().equalsIgnoreCase(string))
                return value;
        return defValue;
    }//from   w ww . j a  va  2 s .  c  o  m
}

Related

  1. awaitThreadState(Thread thread, long maxWaitMillis, Thread.State first, Thread.State... rest)
  2. copyOf(Collection src, Class type)
  3. deepCloneEnumSet(final EnumSet set)
  4. encode(EnumSet set)
  5. extractTypes(final Class type)
  6. getDataFromEnum(Class enumClass)
  7. getDataInEnumClass(String enumClassName)
  8. getEnumFromString(Class enumClass, String enumValue, boolean compareByValue)
  9. nativeLoadEnumDefaultValues(Class enumType)