public static <E extends Enum<E>> E readEnum(Class<E> clazz, DataInput in) throws IOException {

    InternalDataSerializer.checkIn(in);

    if (clazz == null) {
      throw new NullPointerException(
          "the enum class to deserialize is null");
    } else if (!clazz.isEnum()) {
      throw new IllegalArgumentException(
          String.format("Class %s is not an enum", clazz.getName()));
    }

    int ordinal = InternalDataSerializer.readArrayLength(in);

    return getEnumConstantsForClass(clazz)[ordinal];
  }
Reads a <code>Enum constant</code> from <code>DataInput</code>. Unlike standard java
serialization which serializes both the enum name String and the ordinal, GemFire only
serializes the ordinal byte, so be careful about using the correct enum class. Also, for
backward compatibility new enum constants should only be added to the end of the enum
type.<br>
Example: <code>DAY_OF_WEEK d = DataSerializer.readEnum(DAY_OF_WEEK.class, in);</code>

@param <E> the type of Enum
@param clazz the Enum class to deserialize to
@param in the {@link DataInput} to read from
@return the deserialized Enum

@since GemFire 6.5
@see #writeEnum(Enum, DataOutput)
@throws IOException if a problem occurs while reading from <code>in</code>
@throws ArrayIndexOutOfBoundsException if the wrong enum class/enum class with a different
        version and less enum constants is used
geode-core/src/main/java/org/apache/geode/DataSerializer.java