org.jboss.lang
Class EnumImpl<E extends EnumImpl<E>>

java.lang.Object
  extended by org.jboss.lang.EnumImpl<E>
All Implemented Interfaces:
Serializable, Comparable<E>

public abstract class EnumImpl<E extends EnumImpl<E>>
extends Object
implements Serializable, Comparable<E>

Mapping of the java.lang.Enum.

Version:
$Revision: 227 $
Author:
Adrian Brock, Scott.Stark@jboss.org
See Also:
Serialized Form

Constructor Summary
protected EnumImpl(String name, int ordinal)
          Create an enum type.
 
Method Summary
protected  Object clone()
           
 int compareTo(E o)
           
 boolean equals(Object other)
           
 Class<E> getDeclaringClass()
           
 int hashCode()
           
 String name()
           
 int ordinal()
           
 String toString()
           
static
<T extends EnumImpl<T>>
T
valueOf(Class<T> enumType, String name)
          Obtain the Enum of enumType for the given name.
static
<T extends EnumImpl<T>>
T[]
values(Class<T> enumType)
          Obtain the array of Enums for enumType.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EnumImpl

protected EnumImpl(String name,
                   int ordinal)
Create an enum type. This registers the enum with the class enumConstants to support the valueOf, values methods.

Parameters:
name - - the string representation of the enum
ordinal - - the int representation of the enum
See Also:
org.jboss.weaver.retro.WeaverRetroJdk14#rewriteEnum(ClassLoader, CompilerClassInfo)
Method Detail

valueOf

public static <T extends EnumImpl<T>> T valueOf(Class<T> enumType,
                                                String name)
Obtain the Enum of enumType for the given name.

Parameters:
enumType - - the class for the enum type
name - - the string representation of the enum type
Returns:
the T enum type if found, null otherwise

values

public static <T extends EnumImpl<T>> T[] values(Class<T> enumType)
Obtain the array of Enums for enumType.

Parameters:
enumType - - the class for the enum type
Returns:
the T[] enum types if enumType is a registered type, null otherwise

name

public final String name()

ordinal

public final int ordinal()

toString

public String toString()
Overrides:
toString in class Object

equals

public final boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public final int compareTo(E o)
Specified by:
compareTo in interface Comparable<E extends EnumImpl<E>>

clone

protected final Object clone()
                      throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

getDeclaringClass

public final Class<E> getDeclaringClass()


Copyright © 2005-2007 JBoss, a division of Red Hat, Inc. All Rights Reserved.