public abstract class ApiEnumeration<E extends ApiEnumeration<E>>
extends java.lang.Object
implements java.io.Serializable
The interface language definition type system includes enumerated types. For every such enumerated type a class which extends this class is generated (referred to as enumeration class). The generated class contains public static member fields initialized with instances of the class for each enumeration constant.
In addition, the generated enumeration class contains inner native Java
enum declaraing the same constants. This native enum can be used for more
convenient handling of enumerations, e.g. in usage in switch statements.
The simple name of the inner native enum is always Values.
Example of generated "enumeration class" and its inner native enum:
public final class SourceType extends com.vmware.vapi.bindings.ApiEnumeration{ public static final SourceType FILE = new SourceType("FILE"); public static final SourceType REMOTE = new SourceType("REMOTE"); public enum Values { FILE, REMOTE, _UNKNOWN, } ... }
Example of obtaining native enum constant corresponding to given enumeration class constant
SourceType sourceType = SourceType.FILE;
SourceType.Values nativeEnumValue = sourceType.getEnumValue();
// can use it in switch statement
switch (nativeEnumValue) {
case: ...
}
Note:The generated enumeration class defines constants
representing the values in the current version of the enumerated type.
Newer versions of the enumerated type may contain additional values. Such
newer values are not known at generation and compile time. They are represented
by the _UNKNOWN constant of the native enum and by an instance of the
enumeration class which is not referred by any of the static member
fields of the class. For the enumeration class instances conversion
to and from String is supported, which allows usage of such newer
constants.
// create enumeration class instance for the newer value FOLDER
SourceType sourceType = SourceType.valueOf("FOLDER");
// obtain String representation of the newer value (e.g. received from a
// server which supports newer version of the API
SourceType sourceType = ...
String strValue = sourceType.name();
| Modifier | Constructor and Description |
|---|---|
protected |
ApiEnumeration(java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
protected static <T extends ApiEnumeration<T>> |
buildNameMap(T[] values) |
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
java.lang.String |
name() |
java.lang.String |
toString() |
protected ApiEnumeration(java.lang.String name)
name - enumeration value; must not be nullprotected static <T extends ApiEnumeration<T>> java.util.Map<java.lang.String,T> buildNameMap(T[] values)
values - an array of enumeration values; must not be
nullpublic java.lang.String name()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object