Example usage for java.lang Enum name

List of usage examples for java.lang Enum name

Introduction

In this page you can find the example usage for java.lang Enum name.

Prototype

String name

To view the source code for java.lang Enum name.

Click Source Link

Document

The name of this enum constant, as declared in the enum declaration.

Usage

From source file:org.ow2.sirocco.cloudmanager.core.utils.QueryHelper.java

/**
 * code factoring for getXXX (getMachines, getVolumes,etc)
 * /*  w w w.  j ava  2 s  .c  om*/
 * @param entityType
 * @param em
 * @param tenantId optional, filter request to given tenant
 * @param verifyDeletedState if the query should ignore deleted entities.<br>
 *        Must be set to false if an entity doesn't have a state field
 * @return
 */
@SuppressWarnings({ "rawtypes" })
public static List getEntityList(final String entityType, final EntityManager em, final Integer tenantId,
        final Enum stateToIgnore, final boolean returnPublicEntities) {
    String tenantQuery = "", stateQuery = "";

    if (tenantId != null) {
        if (!returnPublicEntities) {
            tenantQuery = " v.tenant.id=:tenantId ";
        } else {
            tenantQuery = " (v.tenant.id=:tenantId OR v.visibility = org.ow2.sirocco.cloudmanager.model.cimi.extension.Visibility.PUBLIC) ";
        }
    }
    if (stateToIgnore != null) {
        if (tenantQuery.length() > 0) {
            stateQuery = " AND ";
        }
        stateQuery = stateQuery + " v.state<>" + stateToIgnore.getClass().getName() + "." + stateToIgnore.name()
                + " ";
    }
    return em.createQuery(
            "SELECT v FROM " + entityType + " v WHERE " + tenantQuery + stateQuery + " ORDER BY v.id DESC")
            .setParameter("tenantId", tenantId).getResultList();

}

From source file:edu.cornell.kfs.module.receiptProcessing.batch.CsvBatchInputFileTypeBase.java

/**
 * build the csv header list base on provided csv enum class
 * //ww  w .  j ava  2  s .  co  m
 * @return
 */
@SuppressWarnings("rawtypes")
protected List<String> getCsvHeaderList() {
    List<String> headerList = new ArrayList<String>();
    EnumSet<CSVEnum> enums = EnumSet.allOf((Class) csvEnumClass);
    for (Enum<CSVEnum> e : enums) {
        headerList.add(e.name());
    }
    return headerList;
}

From source file:com.google.api.server.spi.config.annotationreader.ApiAnnotationIntrospector.java

@Override
public String findEnumValue(Enum<?> value) {
    return value.name();
}

From source file:sk.lazyman.gizmo.web.PageTemplate.java

public StringResourceModel createStringResource(Enum e) {
    String resourceKey = e.getDeclaringClass().getSimpleName() + "." + e.name();
    return createStringResource(resourceKey);
}

From source file:org.fornax.cartridges.sculptor.framework.propertyeditor.EnumEditor.java

/**
 * Format the Enum as translated String//from  ww w . j  a v  a  2s.c om
 */
public String getAsText() {
    Enum<?> value = (Enum<?>) getValue();
    if (value == null) {
        return "";
    }

    String text = getMessagesAccessor().getMessage(messagesKeyPrefix + value.name(), (String) null);
    if (text == null) {
        return value.toString();
    } else {
        return text;
    }
}

From source file:foam.lib.xml.Outputter.java

protected void outputEnum(Enum<?> value) {
    writer_.append(value.name());
}

From source file:io.apiman.manager.api.es.util.XContentBuilder.java

/**
 * @param fieldName//from   ww  w.  ja va2  s .co m
 * @param array
 * @throws IOException
 */
public XContentBuilder array(String fieldName, Enum<?>[] array) throws IOException {
    json.writeArrayFieldStart(fieldName);
    for (Enum<?> item : array) {
        json.writeString(item.name());
    }
    json.writeEndArray();
    return this;
}

From source file:nl.strohalm.cyclos.utils.lucene.DocumentBuilder.java

/**
 * Adds an enumerated field//from w  w  w  . jav  a2 s  . c om
 */
public DocumentBuilder add(final String name, final Enum<?> enumerated) {
    if (enumerated != null) {
        add(name, enumerated.name(), false);
    }
    return this;
}

From source file:net.kaczmarzyk.spring.data.jpa.domain.EqualEnum.java

private List<Enum<?>> findMatchingEnumConstants(Class<? extends Enum<?>> enumClass) {
    List<String> searchedNamesCopy = new ArrayList<>(Arrays.asList(searchedNames));
    List<Enum<?>> matchingEnumConstants = new ArrayList<>();
    Enum<?>[] enumConstants = enumClass.getEnumConstants();
    for (Enum<?> enumConstant : enumConstants) {
        Iterator<String> i = searchedNamesCopy.iterator();
        while (i.hasNext()) {
            if (enumConstant.name().equals(i.next())) {
                matchingEnumConstants.add(enumConstant);
                i.remove();// w  w w .j a v  a  2s.  co m
            }
        }
    }
    if (searchedNamesCopy.size() > 0) {
        throw new IllegalArgumentException(
                "The following enum constants do not exists: " + StringUtils.join(searchedNamesCopy, ", "));
    }
    return matchingEnumConstants;
}

From source file:io.cortical.services.ImageRetinaApiImpl.java

private String name(Enum<?> enumItem) {
    if (enumItem != null) {
        return enumItem.name();
    }//from   w w w  .j av  a2s.  co m
    return null;
}