Example usage for org.apache.commons.lang.enums EnumUtils getEnum

List of usage examples for org.apache.commons.lang.enums EnumUtils getEnum

Introduction

In this page you can find the example usage for org.apache.commons.lang.enums EnumUtils getEnum.

Prototype

public static ValuedEnum getEnum(Class enumClass, int value) 

Source Link

Document

Gets a ValuedEnum object by class and value.

Usage

From source file:org.jbpm.bpel.persistence.db.type.EnumType.java

public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
    // get enum constant name
    String enumName = (String) Hibernate.STRING.nullSafeGet(rs, names[0]);
    // resolve enum constant
    Enum enumConstant = enumName != null ? EnumUtils.getEnum(enumClass, enumName) : null;
    return enumConstant;
}

From source file:org.sipfoundry.sipxconfig.common.EnumUserType.java

/**
 * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[],
 *      java.lang.Object)/*from   ww w  .  j a  v a 2  s  .  com*/
 */
public Object nullSafeGet(ResultSet rs, String[] names, Object owner_) throws SQLException {
    String enumCode = (String) Hibernate.STRING.nullSafeGet(rs, names[0]);

    return EnumUtils.getEnum(m_enumClass, enumCode);
}

From source file:org.springmodules.commons.lang.CommonsEnumPropertyEditor.java

/**
 * Turns a string to an enum.  The string must be a enum name.
 * @param text the enum name/* w ww .j a  v  a2 s . c o m*/
 * @see java.beans.PropertyEditor#setAsText(java.lang.String)
 */
public void setAsText(String text) throws IllegalArgumentException {
    if (this.allowEmpty && !StringUtils.hasText(text)) {
        setValue(null);
    } else {
        Enum eNum = EnumUtils.getEnum(enumClass, text);
        if (eNum != null) {
            setValue(eNum);
        } else {
            throw new IllegalArgumentException("Invalid enum name: " + text);
        }
    }
}