Example usage for org.apache.commons.lang3 EnumUtils getEnum

List of usage examples for org.apache.commons.lang3 EnumUtils getEnum

Introduction

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

Prototype

public static <E extends Enum<E>> E getEnum(final Class<E> enumClass, final String enumName) 

Source Link

Document

Gets the enum for the class, returning null if not found.

This method differs from Enum#valueOf in that it does not throw an exception for an invalid enum name.

Usage

From source file:io.apiman.gateway.platforms.vertx3.api.auth.KeycloakOAuthFactory.java

private static OAuth2FlowType toEnum(String flowType) {
    return EnumUtils.getEnum(OAuth2FlowType.class, flowType.toUpperCase());
}

From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.MDRCacheServiceBean.java

/**
 * This function checks that all the IdType values passed to the function exist in MDR code list or not
 *
 * @param listName      - Values passed would be checked agaist this MDR list
 * @param valuesToMatch - IdType list--Values from each instance will be checked agaist ListName
 * @return True -> if all values are found in MDR list specified. False -> If even one value is not matching with MDR list
 *///from  w  w w . j a  va  2s  .c om
public boolean isIdTypePresentInMDRList(String listName, List<IdType> valuesToMatch) {
    MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, listName);
    if (anEnum == null) {
        return false;
    }
    List<String> codeListValues = getValues(anEnum);
    if (CollectionUtils.isEmpty(valuesToMatch) || CollectionUtils.isEmpty(codeListValues)) {
        return false;
    }
    for (IdType codeType : valuesToMatch) {
        if (!codeListValues.contains(codeType.getValue()))
            return false;
    }
    return true;
}

From source file:com.adobe.acs.commons.workflow.bulk.execution.model.Workspace.java

public Status getStatus() {
    // Refresh state before getting the status.
    // Note, this gets the value from the session state, and not the cached Sling Model value as this value can change over the life of the SlingModel.
    resourceResolver.refresh();/*w  w  w .  j a  v a  2  s. c  om*/
    status = resource.getValueMap().get(PN_STATUS, Status.NOT_STARTED.toString());

    return EnumUtils.getEnum(Status.class, status);
}

From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.MDRCacheServiceBean.java

/**
 * This function checks that all the CodeType values passed to the function exist in MDR code list or not
 *
 * @param listName      - Values passed would be checked agaist this MDR list
 * @param valuesToMatch - CodeType list--Values from each instance will be checked agaist ListName
 * @return True -> if all values are found in MDR list specified. False -> If even one value is not matching with MDR list
 */// w  ww  . j  a  v a2s  .  c  om
public boolean isCodeTypePresentInMDRList(String listName, List<CodeType> valuesToMatch) {
    MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, listName);
    if (anEnum == null) {
        return false;
    }
    List<String> codeListValues = getValues(anEnum);
    if (CollectionUtils.isEmpty(valuesToMatch) || CollectionUtils.isEmpty(codeListValues)) {
        return false;
    }
    for (CodeType codeType : valuesToMatch) {
        if (!codeListValues.contains(codeType.getValue())) {
            return false;
        }
    }
    return true;
}

From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.MDRCacheServiceBean.java

public boolean isCodeTypeListIdPresentInMDRList(String listName, List<CodeType> valuesToMatch) {
    MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, listName);
    if (anEnum == null) {
        return false;
    }// w  w w .  j a va  2  s .co m
    List<String> codeListValues = getValues(anEnum);
    if (CollectionUtils.isEmpty(valuesToMatch) || CollectionUtils.isEmpty(codeListValues)) {
        return false;
    }
    for (CodeType codeType : valuesToMatch) {
        if (!codeListValues.contains(codeType.getListId()))
            return false;
    }
    return true;
}

From source file:com.adobe.acs.commons.workflow.bulk.execution.model.Workspace.java

public SubStatus getSubStatus() {
    // Refresh state before getting the status.
    // Note, this gets the value from the session state, and not the cached Sling Model value as this value can change over the life of the SlingModel.
    resourceResolver.refresh();//from w  w  w  .  j  a v  a 2  s . co  m
    subStatus = resource.getValueMap().get(PN_SUB_STATUS, String.class);

    if (subStatus != null) {
        return EnumUtils.getEnum(SubStatus.class, subStatus);
    } else {
        return null;
    }
}

From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.MDRCacheServiceBean.java

/**
 * This function checks that the IdType exist in MDR code list or not.
 * The MDR list is defined by the property schemeId from the IdType
 *
 * @param id - IdType that will be checked against ListName
 * @return true when it exists/*from  w  w  w . jav a  2 s  . c o m*/
 */
public boolean isIdTypePresentInMDRList(IdType id) {
    if (id == null) {
        return false;
    }
    String schemeId = id.getSchemeId();
    String value = id.getValue();
    MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, schemeId);
    if (anEnum == null) {
        return false;
    }
    List<String> codeListValues = getValues(anEnum);
    return codeListValues.contains(value);
}

From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.MDRCacheServiceBean.java

/**
 * This method gets value from DataType Column of MDR list for the matching record. Record will be matched with CODE column
 *
 * @param listName  MDR list name to be matched with
 * @param codeValue value for CODE column to be matched with
 * @return DATATYPE column value for the matching record
 *//*from w  ww. j  a  v  a  2  s  .c o m*/
public String getDataTypeForMDRList(String listName, String codeValue) {
    MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, listName);
    if (anEnum == null || codeValue == null) {
        return StringUtils.EMPTY;
    }
    List<ObjectRepresentation> representations = cache.getEntry(anEnum);
    boolean valueFound = false;
    if (CollectionUtils.isNotEmpty(representations)) {
        for (ObjectRepresentation representation : representations) {

            List<ColumnDataType> columnDataTypes = representation.getFields();
            if (CollectionUtils.isEmpty(columnDataTypes)) {
                continue;
            }
            for (ColumnDataType columnDataType : columnDataTypes) {
                if ("code".equals(columnDataType.getColumnName())
                        && columnDataType.getColumnValue().equals(codeValue)) {
                    valueFound = true;
                    break;
                }
            }
            if (valueFound) {
                for (ColumnDataType columnDataType : columnDataTypes) {
                    if ("dataType".equals(columnDataType.getColumnName())) {
                        return columnDataType.getColumnValue();
                    }
                }
            }
        }
    }
    return StringUtils.EMPTY;
}

From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java

/**
 * Does some thing in old style.//from   ww  w .j av  a 2s.com
 *
 * @deprecated use {@link #MDRCacheRuleService()} instead.
 */
@Deprecated
public boolean isPresentInMDRList(String listName, String codeValue) {
    MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, listName);
    if (anEnum == null) {
        log.trace(THE_LIST + listName + DOESN_T_EXIST_IN_MDR_MODULE);
        return false;
    }
    List<String> values = MDRCacheHolder.getInstance().getList(anEnum);
    if (CollectionUtils.isNotEmpty(values)) {
        return values.contains(codeValue);
    }
    return false;
}

From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java

/**
 * Does some thing in old style./* w w  w .  java  2s  .  c  om*/
 *
 * @deprecated use {@link #MDRCacheRuleService()} instead.
 */
@Deprecated
public boolean isCodeTypePresentInMDRList(List<CodeType> valuesToMatch) {
    if (CollectionUtils.isEmpty(valuesToMatch) || CollectionUtils.isEmpty(valuesToMatch)) {
        return false;
    }

    for (CodeType codeType : valuesToMatch) {
        if (codeType == null || codeType.getValue() == null || codeType.getListId() == null) {
            return false;
        }

        MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, codeType.getListId());
        if (anEnum == null) {
            log.trace(THE_LIST + codeType.getListId() + DOESN_T_EXIST_IN_MDR_MODULE);
            return false;
        }

        List<String> codeListValues = MDRCacheHolder.getInstance().getList(anEnum);
        if (!codeListValues.contains(codeType.getValue())) {
            return false;
        }
    }
    return true;
}