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:com.rapleaf.jack.ModelWithId.java

@Override
public int hashCode() {
    if (cachedHashCode == 0) {
        HashCodeBuilder hcb = new HashCodeBuilder();
        hcb.append(this.getClass().getName());
        hcb.append(getId());//  w  w  w .j  av  a  2  s.  c o m
        for (Enum field : getFieldSet()) {
            hcb.append(field.name());
            Object value = getField(field.name());
            if (value != null) {
                hcb.append(value);
            }
        }
        cachedHashCode = hcb.toHashCode();
    }
    return cachedHashCode;
}

From source file:org.n52.sos.service.it.MockHttpClient.java

@Override
public MockHttpClient query(Enum<?> key, Enum<?> value) {
    return query(key.name(), value.name());
}

From source file:de.escalon.hypermedia.hydra.serialize.EnumSerializer.java

@Override
public void serialize(Enum<?> value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException, JsonGenerationException {
    if (value != null) {
        jgen.writeString(value.name());
    }/*  www .  j a  va 2  s.  c om*/
}

From source file:com.mg.framework.utils.MiscUtils.java

/**
 *  ? ? ? ? //ww  w . j a  va 2s . c o  m
 *
 * @param value  ? ? 
 * @param locale 
 * @return ? ?
 * @throws NullPointerException ? <code>value == null</code>
 */
public static String getEnumTextRepresentation(Enum<?> value, Locale locale) {
    if (value == null)
        throw new NullPointerException();

    String result;
    EnumConstantText textAnnot = null;
    Field fld = ReflectionUtils.findDeclaredField(value.getClass(), value.name());
    textAnnot = fld.getAnnotation(EnumConstantText.class);
    if (textAnnot != null)
        result = UIUtils.loadL10nText(locale, textAnnot.value());
    else
        result = value.name();
    return result;
}

From source file:org.apache.hive.spark.counter.SparkCounters.java

public void createCounter(Enum<?> key) {
    createCounter(key.getDeclaringClass().getName(), key.name());
}

From source file:org.apache.hive.spark.counter.SparkCounters.java

public SparkCounter getCounter(Enum<?> key) {
    return getCounter(key.getDeclaringClass().getName(), key.name());
}

From source file:org.netxilia.api.impl.format.EnumerationFormatter.java

private String enumValue(String enumValueProperty, Enum<?> enumItem) {
    if (enumValueProperty == null || ENUM_VALUE_NAME.equals(enumValueProperty)) {
        return enumItem.name();
    }/*from   w w w.  j  a va  2s.c o  m*/

    if (ENUM_VALUE_ORDINAL.equals(enumValueProperty)) {
        return String.valueOf(enumItem.ordinal());
    }

    try {
        return BeanUtils.getSimpleProperty(enumItem, enumValueProperty);
    } catch (Exception e) {
        throw new IllegalArgumentException("Unknown property:" + enumItem.getClass() + "." + enumValueProperty);
    }
}

From source file:org.openregistry.core.repository.jpa.JpaReferenceRepository.java

public Type findType(final DataTypes type, final Enum value) {
    return findType(type, value.name());
}

From source file:org.apache.hive.spark.counter.SparkCounters.java

public void increment(Enum<?> key, long incrValue) {
    increment(key.getDeclaringClass().getName(), key.name(), incrValue);
}

From source file:com.rapleaf.jack.ModelWithId.java

public boolean equals(ModelWithId obj) {
    if (obj == null)
        return false;
    if (!this.getClass().getName().equals(obj.getClass().getName())) {
        return false;
    }//from w w  w  . j  a v a 2s. c o m
    if (getId() != obj.getId()) {
        return false;
    }

    for (Enum field : getFieldSet()) {
        Object value1 = getField(field.name());
        Object value2 = obj.getField(field.name());
        if (value1 != null) {
            if (value1 instanceof byte[]) {
                value1 = ByteBuffer.wrap((byte[]) value1);
                value2 = ByteBuffer.wrap((byte[]) value2);
            }
            if (!value1.equals(value2)) {
                return false;
            }
        } else {
            if (value2 != null) {
                return false;
            }
        }
    }
    return true;
}