org.eclipse.gmf.runtime.common.core.util
Class EnumeratedType
java.lang.Object
org.eclipse.gmf.runtime.common.core.util.EnumeratedType
-
All Implemented Interfaces:
- java.io.Serializable
-
Direct Known Subclasses:
-
AbstractDropTargetListener.WorkIndicatorType,
ClipboardState,
ExecutionStrategy,
GravityDirectionType,
ProviderPriority
-
public abstract class EnumeratedType
- extends java.lang.Object
- implements java.io.Serializable
An enumeration of constants based on the typesafe enum pattern.
-
See Also:
-
Serialized Form
Constructor Summary
|
protected
|
EnumeratedType
(java.lang.String name,
int ordinal)
Concrete subclasses should define a private static field to generate
ordinals and a private constructor as follows:
private static int nextOrdinal = 0;
private Subclass(String name) {
super(name, nextOrdinal++);
}
|
Method Summary
|
boolean
|
equals
(java.lang.Object object)
Indicates whether some other object is "equal to" this enumerated type. |
java.lang.String
|
getName
()
Retrieves the value of the name instance variable. |
int
|
getOrdinal
()
Retrieves the value of the ordinal instance variable. |
protected abstract java.util.List
|
getValues
()
Retrieves the list of constants for this enumerated type. |
int
|
hashCode
()
Retrieves a hash code value for this enumerated type. |
protected java.lang.Object
|
readResolve
()
Designates an alternative object to be used when reading an enumerated
type from a stream. |
java.lang.String
|
toString
()
Retrieves a textual representation of this enumerated type. |
Methods inherited from class java.lang.Object
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
|
EnumeratedType
protected EnumeratedType(java.lang.String name,
int ordinal)
- Concrete subclasses should define a private static field to generate
ordinals and a private constructor as follows:
private static int nextOrdinal = 0;
private Subclass(String name) {
super(name, nextOrdinal++);
}
-
Parameters:
-
name
- The name of the new enumerated type. -
ordinal
- The ordinal for the new enumerated type.
getName
public java.lang.String getName()
- Retrieves the value of the
name
instance variable.
-
-
-
Returns:
- The value of the
name
instance variable.
getOrdinal
public final int getOrdinal()
- Retrieves the value of the
ordinal
instance variable.
-
-
-
Returns:
- The value of the
ordinal
instance variable.
getValues
protected abstract java.util.List getValues()
- Retrieves the list of constants for this enumerated type.
Concrete subclasses should define a private static array of values and
a(n) (final) implementation of this method as follows:
private static final Subclass[] VALUES = { ... };
protected final List getValues() {
return Collections.unmodifiableList(Arrays.asList(VALUES));
}
-
-
-
Returns:
- The list of constants for this enumerated type.
equals
public final boolean equals(java.lang.Object object)
- Indicates whether some other object is "equal to" this enumerated type.
-
-
Overrides:
-
equals
in class java.lang.Object
-
-
Parameters:
-
object
- The reference object with which to compare.
-
Returns:
-
true
if this enumerated type is the same as the
object argument; false
otherwise. -
See Also:
-
Object.equals(Object)
hashCode
public final int hashCode()
- Retrieves a hash code value for this enumerated type. This method is
supported for the benefit of hashtables such as those provided by
java.util.Hashtable
.
-
-
Overrides:
-
hashCode
in class java.lang.Object
-
-
Returns:
- A hash code value for this enumerated type.
-
See Also:
-
Object.hashCode()
toString
public java.lang.String toString()
- Retrieves a textual representation of this enumerated type.
-
-
Overrides:
-
toString
in class java.lang.Object
-
-
Returns:
- A textual representation of this enumerated type.
-
See Also:
-
Object.toString()
readResolve
protected final java.lang.Object readResolve()
throws java.io.ObjectStreamException
- Designates an alternative object to be used when reading an enumerated
type from a stream.
-
-
-
Returns:
- The alternative enumerated type object.
-
Throws:
-
java.io.ObjectStreamException
-
See Also:
-
Serializable
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.