org.openspml.v2.util
Class EnumConstant

java.lang.Object
  extended byorg.openspml.v2.util.EnumConstant
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BasicStringEnumConstant

public class EnumConstant
extends java.lang.Object
implements java.io.Serializable

Many thanks to JavaWorld. http://www.javaworld.com/javaworld/javatips/jw-javatip133.html

All subclasses of this class:

  • Should be immutable, e.g. only final private fields in the instances.
  • Don't need to override hashCode - object refs suffice.
  • Should be careful with static fields that are not of this type.
  • Should be final because fieldnames (public static final) could collide.
  • Author:
    kent.spaulding@sun.com

    Date: Feb 1, 2006

    See Also:
    Serialized Form

    Constructor Summary
    EnumConstant()
               
     
    Method Summary
    protected static java.util.List getEnumConstants(java.lang.Class cls)
              Return the constants, in the order declared.
     java.lang.Object readResolve()
              Replace the deserialized instance with the local static instance to allow correct usage of == operator
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    EnumConstant

    public EnumConstant()
    Method Detail

    readResolve

    public java.lang.Object readResolve()
                                 throws java.io.ObjectStreamException
    Replace the deserialized instance with the local static instance to allow correct usage of == operator

    Throws:
    java.io.ObjectStreamException

    getEnumConstants

    protected static java.util.List getEnumConstants(java.lang.Class cls)
    Return the constants, in the order declared.

    Subclasses, e.g. FooEnum with a constant named FOO, should implement:

     public static FooEnum[] getConstants() {
       List temp = FOO.getEnumConstants();
       return (FooEnum[]) temp.toArray(new FooEnum[temp.size()]);
     }
     

    Returns:
    an array of constants, as defined in the class.


    Copyright © Sun Microsystems, Inc. All Rights Reserved.