Package com.alibaba.common.lang.enumeration.Enum

Examples of com.alibaba.common.lang.enumeration.Enum.EnumType


     * @param name 枚举量的名称
     *
     * @return 枚举量, 如果不存在, 则返回<code>null</code>
     */
    public static Enum getEnumByName(Class enumClass, String name) {
        EnumType enumType = getEnumType(enumClass);

        if (enumType.enumList.size() != enumType.nameMap.size()) {
            enumType.populateNames(enumClass);
        }

        return (Enum) enumType.nameMap.get(name);
    }
View Full Code Here


                                                                            enumClass.getName()
                                                                        }));
            }

            Map      entryMap = getEnumEntryMap(enumClass);
            EnumType enumType = (EnumType) entryMap.get(enumClass.getName());

            if (enumType == null) {
                Method createEnumTypeMethod = findStaticMethod(enumClass,
                                                               EnumConstant.CREATE_ENUM_TYPE_METHOD_NAME,
                                                               new Class[0]);

                if (createEnumTypeMethod != null) {
                    try {
                        enumType = (EnumType) createEnumTypeMethod.invoke(null, new Object[0]);
                    } catch (IllegalAccessException e) {
                    } catch (IllegalArgumentException e) {
                    } catch (InvocationTargetException e) {
                    } catch (ClassCastException e) {
                    }
                }

                if (enumType != null) {
                    entryMap.put(enumClass.getName(), enumType);
                   
                    // 在JDK5下面,class loader完成并不意味着所有的常量被装配
                    // 下面的代码强制装配常量。
                    enumType.populateNames(enumClass);
                }
            }

            if (enumType == null) {
                throw new UnsupportedOperationException(MessageFormat.format(EnumConstant.FAILED_CREATING_ENUM_TYPE,
View Full Code Here

TOP

Related Classes of com.alibaba.common.lang.enumeration.Enum.EnumType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.