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.apache.hadoop.hbase.io.asyncfs.FanOutOneBlockAsyncDFSOutputHelper.java

private static StorageTypeSetter createStorageTypeSetter() {
    final Method setStorageTypeMethod;
    try {/*from w  w w . j  a va2  s  .  c  om*/
        setStorageTypeMethod = OpWriteBlockProto.Builder.class.getMethod("setStorageType",
                StorageTypeProto.class);
    } catch (NoSuchMethodException e) {
        LOG.debug("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:it.unimi.dsi.util.Properties.java

public void addProperties(final Enum<?> key, final String[] s) {
    for (int i = 0; i < s.length; i++)
        super.addProperty(key.name().toLowerCase(), s[i]);
}

From source file:com.cedarsoft.serialization.jackson.AbstractJacksonSerializer.java

public void serializeEnum(@Nonnull Enum<?> enumValue, @Nonnull String propertyName,
        @Nonnull JsonGenerator serializeTo) throws IOException {
    serializeTo.writeStringField(propertyName, enumValue.name());
}

From source file:org.batoo.jpa.core.impl.jdbc.BasicColumn.java

/**
 * Converts the value corresponding to enum or temporal type
 * /*from ww w  .  jav  a2  s  .c  om*/
 * @param value
 *            the raw value
 * @return the converted value
 * 
 * @since $version
 * @author hceylan
 */
public Object convertValue(final Object value) {
    if (value == null) {
        return null;
    }

    if (this.temporalType != null) {
        switch (this.temporalType) {
        case DATE:
            if (value instanceof java.sql.Date) {
                return value;
            }

            if (value instanceof Date) {
                return new java.sql.Date(((Date) value).getTime());
            }

            return new java.sql.Date(((Calendar) value).getTimeInMillis());
        case TIME:
            if (value instanceof java.sql.Time) {
                return value;
            }

            if (value instanceof Date) {
                return new java.sql.Time(((Date) value).getTime());
            }

            return new java.sql.Time(((Calendar) value).getTimeInMillis());
        case TIMESTAMP:
            if (value instanceof java.sql.Timestamp) {
                return value;
            }

            if (value instanceof Date) {
                return new java.sql.Timestamp(((Date) value).getTime());
            }

            return new java.sql.Timestamp(((Calendar) value).getTimeInMillis());
        }
    }

    if (this.numberType != null) {
        return ReflectHelper.convertNumber((Number) value, this.numberType);
    }

    if (this.enumType == null) {
        return value;
    }

    final Enum<?> enumValue = (Enum<?>) value;
    if (this.enumType == EnumType.ORDINAL) {
        return enumValue.ordinal();
    }

    return enumValue.name();
}

From source file:org.waarp.common.json.AdaptativeJsonHandler.java

/**
 * /*from  ww  w  .  j  a  va  2s . c  o m*/
 * @param node
 * @param field
 * @param value
 */
public final void setValue(ObjectNode node, Enum<?> field, int value) {
    node.put(field.name(), value);
}

From source file:org.waarp.common.json.AdaptativeJsonHandler.java

/**
 * /*from   w w w. j a  va  2 s  . c o m*/
 * @param node
 * @param field
 * @param value
 */
public final void setValue(ObjectNode node, Enum<?> field, long value) {
    node.put(field.name(), value);
}

From source file:org.waarp.common.json.AdaptativeJsonHandler.java

/**
 * //from w w  w.  ja  v a2s  . co m
 * @param node
 * @param field
 * @return the String if the field exists, else null
 */
public final String getString(ObjectNode node, Enum<?> field) {
    return getValue(node, field.name(), (String) null);
}

From source file:org.waarp.common.json.AdaptativeJsonHandler.java

/**
 * /*from  ww  w. ja v  a  2 s.  c  om*/
 * @param node
 * @param field
 * @param value
 */
public final void setValue(ObjectNode node, Enum<?> field, double value) {
    node.put(field.name(), value);
}

From source file:org.waarp.common.json.AdaptativeJsonHandler.java

/**
 * /*w  w  w. ja v a 2 s .  co  m*/
 * @param node
 * @param field
 * @param value
 */
public final void setValue(ObjectNode node, Enum<?> field, boolean value) {
    node.put(field.name(), value);
}

From source file:org.gbif.dwca.io.DwcaWriter.java

/**
 * Null safe convenience method to write enumeration values.
 * See addCoreColumn(Term term, String value) for docs
 *//* w  w w  .j  av  a  2 s . c om*/
public void addCoreColumn(Term term, @Nullable Enum value) {
    addCoreColumn(term, value == null ? null : value.name().toLowerCase().replaceAll("_", " "));
}