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.structr.core.graph.IndexRelationshipCommand.java

private void removeRelationshipPropertyFromAllIndices(final Relationship rel, final PropertyKey key) {

    for (Enum indexName : (RelationshipIndex[]) arguments.get("relationshipIndices")) {

        indices.get(indexName.name()).remove(rel, key.dbName());

    }//from   www. j  a va2 s . c  o  m
}

From source file:com.flexive.faces.model.FxJSFSelectItem.java

/**
 * Ctor for Enum/*  w ww. ja v a  2s . co m*/
 *
 * @param item Enum
 */
public FxJSFSelectItem(Enum item) {
    super(item, item instanceof ObjectWithLabel ? ((ObjectWithLabel) item).getLabel().getBestTranslation()
            : item.name());
    applyStyle(item);
}

From source file:org.projectforge.export.XlsContentProvider.java

public void putFormat(final Enum<?> col, final String dataFormat) {
    putFormat(col.name(), dataFormat);
}

From source file:org.projectforge.export.XlsContentProvider.java

public void putFormat(final Enum<?> col, final CellFormat cellFormat) {
    putFormat(col.name(), cellFormat);
}

From source file:org.apache.hadoop.hbase.util.FanOutOneBlockAsyncDFSOutputHelper.java

private static StorageTypeSetter createStorageTypeSetter() {
    final Method setStorageTypeMethod;
    try {//from   w w  w .  j  av a  2s.co  m
        setStorageTypeMethod = OpWriteBlockProto.Builder.class.getMethod("setStorageType",
                StorageTypeProto.class);
    } catch (NoSuchMethodException e) {
        LOG.warn("noSetStorageType method found, should be hadoop 2.5-", e);
        return new StorageTypeSetter() {

            @Override
            public Builder set(Builder builder, Enum<?> storageType) {
                return builder;
            }
        };
    }
    ImmutableMap.Builder<String, StorageTypeProto> builder = ImmutableMap.builder();
    for (StorageTypeProto storageTypeProto : StorageTypeProto.values()) {
        builder.put(storageTypeProto.name(), storageTypeProto);
    }
    final ImmutableMap<String, StorageTypeProto> name2ProtoEnum = builder.build();
    return new StorageTypeSetter() {

        @Override
        public Builder set(Builder builder, Enum<?> storageType) {
            Object protoEnum = name2ProtoEnum.get(storageType.name());
            try {
                setStorageTypeMethod.invoke(builder, protoEnum);
            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
                throw new RuntimeException(e);
            }
            return builder;
        }
    };
}

From source file:org.lunarray.model.descriptor.converter.def.DelegatingEnumConverterTool.java

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
// We're checking after the fact.
@Override/*from w  ww. ja  v a 2 s . c o  m*/
public <T> String convertToString(final Class<T> type, final T instance) throws ConverterException {
    Validate.notNull(type, DelegatingEnumConverterTool.TYPE_NULL);
    String result = null;
    if (type.isEnum()) {
        DelegatingEnumConverterTool.LOGGER.debug("Converting to string with type {} with value: {}", type,
                instance);
        @SuppressWarnings("rawtypes")
        // No other way?
        final Class<? extends Enum> enumType = (Class<? extends Enum>) type;
        final Enum<?> enumInstance = enumType.cast(instance);
        if (!CheckUtil.isNull(enumInstance)) {
            result = enumInstance.name();
        }
    } else {
        result = this.converterTool.convertToString(type, instance);
    }
    return result;
}

From source file:org.lunarray.model.descriptor.converter.def.DelegatingEnumConverterTool.java

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
// We're checking after the fact.
@Override/*from   ww  w. j  ava2  s .  c  o m*/
public <T> String convertToString(final Class<T> type, final T instance, final Locale locale)
        throws ConverterException {
    Validate.notNull(type, DelegatingEnumConverterTool.TYPE_NULL);
    String result = null;
    if (type.isEnum()) {
        DelegatingEnumConverterTool.LOGGER.debug(
                "Converting to string with type {} with locale {} and value: {}", type, locale, instance);
        @SuppressWarnings("rawtypes")
        // No other way?
        final Class<? extends Enum> enumType = (Class<? extends Enum>) type;
        final Enum<?> enumInstance = enumType.cast(instance);
        if (!CheckUtil.isNull(enumInstance)) {
            result = enumInstance.name();
        }
    } else {
        result = this.converterTool.convertToString(type, instance, locale);
    }
    return result;
}

From source file:org.lunarray.model.descriptor.converter.def.DelegatingEnumConverterTool.java

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
// We're checking after the fact.
@Override//  w  ww. j  av a  2  s  .  co  m
public <T> String convertToString(final Class<T> type, final T instance, final String format)
        throws ConverterException {
    Validate.notNull(type, DelegatingEnumConverterTool.TYPE_NULL);
    String result = null;
    if (type.isEnum()) {
        DelegatingEnumConverterTool.LOGGER.debug(
                "Converting to string with type {} with format {} and value: {}", type, format, instance);
        @SuppressWarnings("rawtypes")
        // No other way?
        final Class<? extends Enum> enumType = (Class<? extends Enum>) type;
        final Enum<?> enumInstance = enumType.cast(instance);
        if (!CheckUtil.isNull(enumInstance)) {
            result = enumInstance.name();
        }
    } else {
        result = this.converterTool.convertToString(type, instance, format);
    }
    return result;
}

From source file:org.seedstack.seed.core.internal.application.ConfigurationMembersInjector.java

private Enum<? extends ErrorCode> findEnum() {
    Class<? extends Enum<? extends ErrorCode>> errorCodeClass = annotation.errorCodeClass();
    if (errorCodeClass.equals(org.seedstack.seed.core.api.Configuration.ConfigurationErrorCode.class)) {
        errorCodeClass = ApplicationErrorCode.class;
    }//from w  w  w . j a  va  2  s  . c o m

    for (Enum<? extends ErrorCode> enumElement : errorCodeClass.getEnumConstants()) {
        if (enumElement.name().equals(annotation.errorCodeName())) {
            return enumElement;
        }
    }

    return null;
}

From source file:org.lunarray.model.descriptor.converter.def.DelegatingEnumConverterTool.java

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
// We're checking after the fact.
@Override/*from  www.  ja v  a2  s.co m*/
public <T> String convertToString(final Class<T> type, final T instance, final Locale locale,
        final String format) throws ConverterException {
    Validate.notNull(type, DelegatingEnumConverterTool.TYPE_NULL);
    String result = null;
    if (type.isEnum()) {
        DelegatingEnumConverterTool.LOGGER.debug(
                "Converting to string with type {} with locale {}, format {} and value: {}", type, locale,
                format, instance);
        @SuppressWarnings("rawtypes")
        // No other way?
        final Class<? extends Enum> enumType = (Class<? extends Enum>) type;
        final Enum<?> enumInstance = enumType.cast(instance);
        if (!CheckUtil.isNull(enumInstance)) {
            result = enumInstance.name();
        }
    } else {
        result = this.converterTool.convertToString(type, instance, locale, format);
    }
    return result;
}