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.waarp.common.json.AdaptativeJsonHandler.java

/**
 * /*from  w w  w .ja  v a 2s. c  o  m*/
 * @param node
 * @param field
 * @return True if all fields exist
 */
public final boolean exist(ObjectNode node, Enum<?>... field) {
    for (Enum<?> enm : field) {
        if (!node.has(enm.name()))
            return false;
    }
    return true;
}

From source file:com.netflix.nicobar.cassandra.CassandraArchiveRepository.java

/**
 * Generate the CQL to select specific columns by shard number.
 * <pre>//from   w ww  .  jav  a  2  s. co  m
 *      SELECT ${columns}... FROM script_repo WHERE shard_num = ?
 * </pre>
 */
protected String generateSelectByShardCql(EnumSet<?> columns, Integer shardNum) {
    StringBuilder sb = new StringBuilder().append("SELECT ");
    boolean first = true;
    for (Enum<?> column : columns) {
        if (first) {
            first = false;
        } else {
            sb.append(",");
        }
        sb.append(column.name());
    }
    sb.append("\n").append("FROM ").append(cassandra.getColumnFamily()).append("\n").append("WHERE ")
            .append(Columns.shard_num.name()).append(" = ").append(shardNum).append("\n");
    return sb.toString();
}

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

/**
 * //from w ww.ja v a  2 s. c om
 * @param node
 * @param field
 * @param defValue
 * @return the Integer if the field exists, else defValue
 */
public final Integer getValue(ObjectNode node, Enum<?> field, int defValue) {
    return node.path(field.name()).asInt(defValue);
}

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

/**
 * /*from  w  w  w.j av a2  s  .co m*/
 * @param node
 * @param field
 * @param defValue
 * @return the Long if the field exists, else defValue
 */
public final Long getValue(ObjectNode node, Enum<?> field, long defValue) {
    return node.path(field.name()).asLong(defValue);
}

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

/**
 * /* www .  ja v  a 2s .  co m*/
 * @param node
 * @param field
 * @param defValue
 * @return the Double if the field exists, else defValue
 */
public final Double getValue(ObjectNode node, Enum<?> field, double defValue) {
    return node.path(field.name()).asDouble(defValue);
}

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

/**
 * /*from w w  w .j av a2 s.  co m*/
 * @param node
 * @param field
 * @param defValue
 * @return the Boolean if the field exists, else defValue
 */
public final Boolean getValue(ObjectNode node, Enum<?> field, boolean defValue) {
    return node.path(field.name()).asBoolean(defValue);
}

From source file:org.gradle.api.publish.internal.ModuleMetadataFileGenerator.java

private void writeAttributes(AttributeContainer attributes, JsonWriter jsonWriter) throws IOException {
    if (attributes.isEmpty()) {
        return;/*from   w w  w.  j a  va2s.c  om*/
    }
    jsonWriter.name("attributes");
    jsonWriter.beginObject();
    Map<String, Attribute<?>> sortedAttributes = new TreeMap<String, Attribute<?>>();
    for (Attribute<?> attribute : attributes.keySet()) {
        sortedAttributes.put(attribute.getName(), attribute);
    }
    for (Attribute<?> attribute : sortedAttributes.values()) {
        jsonWriter.name(attribute.getName());
        Object value = attributes.getAttribute(attribute);
        if (value instanceof Boolean) {
            Boolean b = (Boolean) value;
            jsonWriter.value(b);
        } else if (value instanceof String) {
            String s = (String) value;
            jsonWriter.value(s);
        } else if (value instanceof Named) {
            Named named = (Named) value;
            jsonWriter.value(named.getName());
        } else if (value instanceof Enum) {
            Enum<?> enumValue = (Enum<?>) value;
            jsonWriter.value(enumValue.name());
        } else {
            throw new IllegalArgumentException(
                    String.format("Cannot write attribute %s with unsupported value %s of type %s.",
                            attribute.getName(), value, value.getClass().getName()));
        }
    }
    jsonWriter.endObject();
}

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

/**
 * /*ww w .  j av  a2 s  . c o  m*/
 * @param node
 * @param field
 * @param defValue
 * @return the String if the field exists, else defValue
 */
public final String getValue(ObjectNode node, Enum<?> field, String defValue) {
    return getValue(node, field.name(), defValue);
}

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

/**
 * //from   w ww.j  ava  2s.  c o m
 * @param node
 * @param field
 * @param defValue
 * @return the byte array if the field exists, else defValue
 */
public final byte[] getValue(ObjectNode node, Enum<?> field, byte[] defValue) {
    return getValue(node, field.name(), defValue);
}

From source file:com.arangodb.impl.InternalGraphDriverImpl.java

private String toLower(Enum<?> e) {
    if (e == null) {
        return null;
    }//from   ww w  .  java2 s .  com
    return e.name().toLowerCase(Locale.US);
}