MCPcopy Create free account
hub / github.com/davidgiven/luje / Enum

Class Enum

lib/java/lang/Enum.java:27–206  ·  view source on GitHub ↗

The superclass of all enumerated types. Actual enumeration types inherit from this class, but extending this class does not make a class an enumeration type, since the compiler needs to generate special information for it.

Source from the content-addressed store, hash-verified

25 * type, since the compiler needs to generate special information for it.
26 */
27public abstract class Enum<E extends Enum<E>> implements Serializable,
28 Comparable<E> {
29
30 private static final long serialVersionUID = -4300926546619394005L;
31
32 private final String name;
33
34 private final int ordinal;
35
36 /**
37 * Constructor for constants of enum subtypes.
38 *
39 * @param name
40 * the enum constant's declared name.
41 * @param ordinal
42 * the enum constant's ordinal, which corresponds to its position
43 * in the enum declaration, starting at zero.
44 */
45 protected Enum(String name, int ordinal) {
46 this.name = name;
47 this.ordinal = ordinal;
48 }
49
50 /**
51 * Returns the name of this enum constant. The name is the field as it
52 * appears in the {@code enum} declaration.
53 *
54 * @return the name of this enum constant.
55 * @see #toString()
56 */
57 public final String name() {
58 return name;
59 }
60
61 /**
62 * Returns the position of the enum constant in the declaration. The first
63 * constant has an ordinal value of zero.
64 *
65 * @return the ordinal value of this enum constant.
66 */
67 public final int ordinal() {
68 return ordinal;
69 }
70
71 /**
72 * Returns a string containing a concise, human-readable description of this
73 * object. In this case, the enum constant's name is returned.
74 *
75 * @return a printable representation of this object.
76 */
77 @Override
78 public String toString() {
79 return name;
80 }
81
82 /**
83 * Compares this object with the specified object and indicates if they are
84 * equal. In order to be equal, {@code object} must be identical to this

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected