commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang/enum Extended1Enum.java Extended3Enum.java Extended2Enum.java EnumTest.java
Date Tue, 04 Feb 2003 18:30:09 GMT
scolebourne    2003/02/04 10:30:08

  Modified:    lang/src/java/org/apache/commons/lang/enum Enum.java
                        ValuedEnum.java
               lang/src/test/org/apache/commons/lang/enum EnumTest.java
  Added:       lang/src/test/org/apache/commons/lang/enum
                        Extended1Enum.java Extended3Enum.java
                        Extended2Enum.java
  Log:
  Update Enum classes to support hierarchy Enum definitions
  
  Revision  Changes    Path
  1.8       +84 -19    jakarta-commons/lang/src/java/org/apache/commons/lang/enum/Enum.java
  
  Index: Enum.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/enum/Enum.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Enum.java	4 Feb 2003 16:56:08 -0000	1.7
  +++ Enum.java	4 Feb 2003 18:30:07 -0000	1.8
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -74,7 +74,8 @@
    * <em>NOTE:</em>Due to the way in which Java ClassLoaders work, comparing
Enum objects
    * should always be done using the equals() method, not ==. The equals() method will
    * try == first so in most cases the effect is the same.
  - * <p>
  + * 
  + * <h4>Simple Enums</h4>
    * To use this class, it must be subclassed. For example:
    *
    * <pre>
  @@ -110,9 +111,51 @@
    * The <code>getEnum</code> and <code>iterator</code> methods are
recommended. 
    * Unfortunately, Java restrictions require these to be coded as shown in each subclass.
    * An alternative choice is to use the {@link EnumUtils} class.
  - * <p>
  + * 
  + * <h4>Subclassed Enums</h4>
  + * A hierarchy of Enum classes can be built. In this case, the superclass is 
  + * unaffected by the addition of subclasses (as per normal Java). The subclasses
  + * may add additional Enum constants <i>of the type of the superclass</i>.
The
  + * query methods on the subclass will return all of the Enum constants from the
  + * superclass and subclass.
  + *
  + * <pre>
  + * public class ExtraColorEnum extends ColorEnum {
  + *   // NOTE: Color enum declared above is final, change that to get this
  + *   // example to compile.
  + *   public static final ColorEnum YELLOW = new ExtraColorEnum("Yellow");
  + *
  + *   private ExtraColorEnum(String color) {
  + *     super(color);
  + *   }
  + * 
  + *   public static ColorEnum getEnum(String color) {
  + *     return (ColorEnum) getEnum(ExtraColorEnum.class, color);
  + *   }
  + * 
  + *   public static Map getEnumMap() {
  + *     return getEnumMap(ExtraColorEnum.class);
  + *   }
  + * 
  + *   public static List getEnumList() {
  + *     return getEnumList(ExtraColorEnum.class);
  + *   }
  + * 
  + *   public static Iterator iterator() {
  + *     return iterator(ExtraColorEnum.class);
  + *   }
  + * }
  + * </pre>
  + * 
  + * This example will return RED, GREEN, BLUE, YELLOW from the List and iterator 
  + * methods in that order. The RED, GREEN and BLUE instances will be the same (==) 
  + * as those from the superclass ColorEnum. Note that YELLOW is declared as a
  + * ColorEnum and not an ExtraColorEnum.
  + * 
  + * <h4>Functional Enums</h4>
    * The enums can have functionality by using anonymous inner classes
    * [Effective Java, Bloch01]:
  + * 
    * <pre>
    * public abstract class OperationEnum extends Enum {
    *   public static final OperationEnum PLUS = new OperationEnum("Plus") {
  @@ -200,11 +243,11 @@
               throw new IllegalArgumentException("The Enum name must not be empty");
           }
           iName = name;
  -        String className = Enum.getEnumClassName(getClass());
  -        Entry entry = (Entry) cEnumClasses.get(className);
  +        Class enumClass = Enum.getEnumClass(getClass());
  +        Entry entry = (Entry) cEnumClasses.get(enumClass);
           if (entry == null) {
  -            entry = new Entry();
  -            cEnumClasses.put(className, entry);
  +            entry = createEntry(getClass());
  +            cEnumClasses.put(enumClass, entry);
           }
           if (entry.map.containsKey(name)) {
               throw new IllegalArgumentException("The Enum name must be unique, '" + name
+ "' has already been added");
  @@ -219,7 +262,7 @@
        * @return the resolved object
        */
       protected Object readResolve() {
  -        Entry entry = (Entry) cEnumClasses.get(Enum.getEnumClassName(getClass()));
  +        Entry entry = (Entry) cEnumClasses.get(Enum.getEnumClass(getClass()));
           if (entry == null) {
               return null;
           }
  @@ -293,6 +336,7 @@
           return Enum.getEnumList(enumClass).iterator();
       }
   
  +    //-----------------------------------------------------------------------
       /**
        * Gets an entry from the map of Enums.
        * 
  @@ -306,17 +350,40 @@
           if (Enum.class.isAssignableFrom(enumClass) == false) {
               throw new IllegalArgumentException("The Class must be a subclass of Enum");
           }
  -        Entry entry = (Entry) cEnumClasses.get(enumClass.getName());
  +        Entry entry = (Entry) cEnumClasses.get(enumClass);
           return entry;
       }
       
       /**
  -     * Convert a class to a class name accounting for inner classes.
  +     * Creates an entry for storing the Enums.
  +     * This accounts for subclassed Enums.
  +     * 
  +     * @param enumClass  the class of the Enum to get
  +     * @return the enum entry
  +     */
  +    private static Entry createEntry(Class enumClass) {
  +        Entry entry = new Entry();
  +        Class cls = enumClass.getSuperclass();
  +        while (cls != null && cls != Enum.class && cls != ValuedEnum.class)
{
  +            Entry loopEntry = (Entry) cEnumClasses.get(cls);
  +            if (loopEntry != null) {
  +                entry.list.addAll(loopEntry.list);
  +                entry.map.putAll(loopEntry.map);
  +                break;  // stop here, as this will already have had superclasses added
  +            }
  +            cls = cls.getSuperclass();
  +        }
  +        return entry;
  +    }
  +    
  +    /**
  +     * Convert a class to the actual common enum class.
  +     * This accounts for anonymous inner classes.
        * 
        * @param cls  the class to get the name for
        * @return the class name
        */
  -    protected static String getEnumClassName(Class cls) {
  +    protected static Class getEnumClass(Class cls) {
           String className = cls.getName();
           int index = className.lastIndexOf('$');
           if (index > -1) {
  @@ -325,15 +392,13 @@
               if (inner.length() > 0 &&
                   inner.charAt(0) >= '0' &&
                   inner.charAt(0) < '9') {
  -                // Strip off anonymous inner class reference.
  -                className = className.substring(0, index);
  +                return cls.getSuperclass();
               }
           }
  -        return className;
  +        return cls;
       }
   
  -    //--------------------------------------------------------------------------------
  -
  +    //-----------------------------------------------------------------------
       /**
        * Retrieve the name of this Enum item, set in the constructor.
        * 
  @@ -359,7 +424,7 @@
           } else if (other.getClass() == this.getClass()) {
               // shouldn't happen, but...
               return iName.equals(((Enum) other).iName);
  -        } else if (other.getClass().getName().equals(this.getClass().getName())) {
  +        } else if (getEnumClass(other.getClass()).getName().equals(getEnumClass(this.getClass()).getName()))
{
               // different classloaders
               try {
                   // try to avoid reflection
  @@ -416,7 +481,7 @@
        * the type name.
        */
       public String toString() {
  -        String shortName = Enum.getEnumClassName(getClass());
  +        String shortName = Enum.getEnumClass(getClass()).getName();
           int pos = shortName.lastIndexOf('.');
           if (pos != -1) {
               shortName = shortName.substring(pos + 1);
  
  
  
  1.5       +4 -3      jakarta-commons/lang/src/java/org/apache/commons/lang/enum/ValuedEnum.java
  
  Index: ValuedEnum.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/enum/ValuedEnum.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ValuedEnum.java	31 Dec 2002 22:39:39 -0000	1.4
  +++ ValuedEnum.java	4 Feb 2003 18:30:07 -0000	1.5
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -204,11 +204,12 @@
        * stripped from the type name.
        */
       public String toString() {
  -        String shortName = Enum.getEnumClassName(getClass());
  +        String shortName = Enum.getEnumClass(getClass()).getName();
           int pos = shortName.lastIndexOf('.');
           if (pos != -1) {
               shortName = shortName.substring(pos + 1);
           }
  +        shortName = shortName.replace('$', '.');
           return shortName + "[" + getName() + "=" + getValue() + "]";
       }
   }
  
  
  
  1.6       +126 -1    jakarta-commons/lang/src/test/org/apache/commons/lang/enum/EnumTest.java
  
  Index: EnumTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/enum/EnumTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EnumTest.java	31 Dec 2002 22:39:39 -0000	1.5
  +++ EnumTest.java	4 Feb 2003 18:30:08 -0000	1.6
  @@ -223,5 +223,130 @@
           assertEquals(3, OperationEnum.PLUS.eval(1, 2));
           assertEquals(-1, OperationEnum.MINUS.eval(1, 2));
       }
  +    
  +    //-----------------------------------------------------------------------
  +    public void testExtended1Get() {
  +        assertSame(Extended1Enum.ALPHA, Extended1Enum.getEnum("Alpha"));
  +        assertSame(Extended1Enum.BETA, Extended1Enum.getEnum("Beta"));
  +        assertSame(null, Extended1Enum.getEnum("Gamma"));
  +        assertSame(null, Extended1Enum.getEnum("Delta"));
  +    }
  +            
  +    public void testExtended2Get() {
  +        assertSame(Extended1Enum.ALPHA, Extended2Enum.ALPHA);
  +        assertSame(Extended1Enum.BETA, Extended2Enum.BETA);
  +        
  +        assertSame(Extended2Enum.ALPHA, Extended2Enum.getEnum("Alpha"));
  +        assertSame(Extended2Enum.BETA, Extended2Enum.getEnum("Beta"));
  +        assertSame(Extended2Enum.GAMMA, Extended2Enum.getEnum("Gamma"));
  +        assertSame(null, Extended2Enum.getEnum("Delta"));
  +    }
  +
  +    public void testExtended3Get() {
  +        assertSame(Extended2Enum.ALPHA, Extended3Enum.ALPHA);
  +        assertSame(Extended2Enum.BETA, Extended3Enum.BETA);
  +        assertSame(Extended2Enum.GAMMA, Extended3Enum.GAMMA);
  +        
  +        assertSame(Extended3Enum.ALPHA, Extended3Enum.getEnum("Alpha"));
  +        assertSame(Extended3Enum.BETA, Extended3Enum.getEnum("Beta"));
  +        assertSame(Extended3Enum.GAMMA, Extended3Enum.getEnum("Gamma"));
  +        assertSame(Extended3Enum.DELTA, Extended3Enum.getEnum("Delta"));
  +    }
  +
  +    public void testExtendedSerialization() {
  +        assertSame(Extended1Enum.ALPHA, SerializationUtils.clone(Extended1Enum.ALPHA));
  +        assertSame(Extended1Enum.BETA, SerializationUtils.clone(Extended1Enum.BETA));
  +        assertSame(Extended2Enum.GAMMA, SerializationUtils.clone(Extended2Enum.GAMMA));
  +        assertSame(Extended3Enum.DELTA, SerializationUtils.clone(Extended3Enum.DELTA));
  +    }
  +
  +    public void testExtendedToString() {
  +        assertEquals("Extended1Enum[Alpha]", Extended1Enum.ALPHA.toString());
  +        assertEquals("Extended1Enum[Beta]", Extended1Enum.BETA.toString());
  +        
  +        assertEquals("Extended1Enum[Alpha]", Extended2Enum.ALPHA.toString());
  +        assertEquals("Extended1Enum[Beta]", Extended2Enum.BETA.toString());
  +        assertEquals("Extended2Enum[Gamma]", Extended2Enum.GAMMA.toString());
  +        
  +        assertEquals("Extended1Enum[Alpha]", Extended3Enum.ALPHA.toString());
  +        assertEquals("Extended1Enum[Beta]", Extended3Enum.BETA.toString());
  +        assertEquals("Extended2Enum[Gamma]", Extended3Enum.GAMMA.toString());
  +        assertEquals("Extended3Enum[Delta]", Extended3Enum.DELTA.toString());
  +    }
  +
  +    public void testExtended1List() {
  +        List list = Extended1Enum.getEnumList();
  +        assertNotNull(list);
  +        assertEquals(2, list.size());
  +        assertEquals(list.size(), Extended1Enum.getEnumMap().keySet().size());
  +        
  +        Iterator it = list.iterator();
  +        assertSame(Extended1Enum.ALPHA, it.next());
  +        assertSame(Extended1Enum.BETA, it.next());
  +    }
  +
  +    public void testExtended2List() {
  +        List list = Extended2Enum.getEnumList();
  +        assertNotNull(list);
  +        assertEquals(3, list.size());
  +        assertEquals(list.size(), Extended2Enum.getEnumMap().keySet().size());
  +        
  +        Iterator it = list.iterator();
  +        assertSame(Extended2Enum.ALPHA, it.next());
  +        assertSame(Extended2Enum.BETA, it.next());
  +        assertSame(Extended2Enum.GAMMA, it.next());
  +    }
  +
  +    public void testExtended3List() {
  +        List list = Extended3Enum.getEnumList();
  +        assertNotNull(list);
  +        assertEquals(4, list.size());
  +        assertEquals(list.size(), Extended3Enum.getEnumMap().keySet().size());
  +        
  +        Iterator it = list.iterator();
  +        assertSame(Extended3Enum.ALPHA, it.next());
  +        assertSame(Extended3Enum.BETA, it.next());
  +        assertSame(Extended3Enum.GAMMA, it.next());
  +        assertSame(Extended3Enum.DELTA, it.next());
  +    }
  +
  +    public void testExtended1Map() {
  +        Map map = Extended1Enum.getEnumMap();
  +        assertNotNull(map);
  +        assertEquals(map.keySet().size(), Extended1Enum.getEnumList().size());
  +        
  +        assertTrue(map.containsValue(Extended1Enum.ALPHA));
  +        assertTrue(map.containsValue(Extended1Enum.BETA));
  +        assertSame(Extended1Enum.ALPHA, map.get("Alpha"));
  +        assertSame(Extended1Enum.BETA, map.get("Beta"));
  +    }
  +
  +    public void testExtended2Map() {
  +        Map map = Extended2Enum.getEnumMap();
  +        assertNotNull(map);
  +        assertEquals(map.keySet().size(), Extended2Enum.getEnumList().size());
  +        
  +        assertTrue(map.containsValue(Extended2Enum.ALPHA));
  +        assertTrue(map.containsValue(Extended2Enum.BETA));
  +        assertTrue(map.containsValue(Extended2Enum.GAMMA));
  +        assertSame(Extended2Enum.ALPHA, map.get("Alpha"));
  +        assertSame(Extended2Enum.BETA, map.get("Beta"));
  +        assertSame(Extended2Enum.GAMMA, map.get("Gamma"));
  +    }
  +
  +    public void testExtended3Map() {
  +        Map map = Extended3Enum.getEnumMap();
  +        assertNotNull(map);
  +        assertEquals(map.keySet().size(), Extended3Enum.getEnumList().size());
  +        
  +        assertTrue(map.containsValue(Extended3Enum.ALPHA));
  +        assertTrue(map.containsValue(Extended3Enum.BETA));
  +        assertTrue(map.containsValue(Extended3Enum.GAMMA));
  +        assertTrue(map.containsValue(Extended3Enum.DELTA));
  +        assertSame(Extended3Enum.ALPHA, map.get("Alpha"));
  +        assertSame(Extended3Enum.BETA, map.get("Beta"));
  +        assertSame(Extended3Enum.GAMMA, map.get("Gamma"));
  +        assertSame(Extended3Enum.DELTA, map.get("Delta"));
  +    }
   
   }
  
  
  
  1.1                  jakarta-commons/lang/src/test/org/apache/commons/lang/enum/Extended1Enum.java
  
  Index: Extended1Enum.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.lang.enum;
  
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  /**
   * Base extended enumeration.
   *
   * @author Stephen Colebourne
   * @version $Id: Extended1Enum.java,v 1.1 2003/02/04 18:30:08 scolebourne Exp $
   */
  public class Extended1Enum extends Enum {
      public static final Extended1Enum ALPHA = new Extended1Enum("Alpha");
      public static final Extended1Enum BETA = new Extended1Enum("Beta");
  
      protected Extended1Enum(String name) {
          super(name);
      }
  
      public static Extended1Enum getEnum(String name) {
          return (Extended1Enum) getEnum(Extended1Enum.class, name);
      }
  
      public static Map getEnumMap() {
          return getEnumMap(Extended1Enum.class);
      }
  
      public static List getEnumList() {
          return getEnumList(Extended1Enum.class);
      }
  
      public static Iterator iterator() {
          return iterator(Extended1Enum.class);
      }
  
  }
  
  
  
  1.1                  jakarta-commons/lang/src/test/org/apache/commons/lang/enum/Extended3Enum.java
  
  Index: Extended3Enum.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.lang.enum;
  
  import java.util.Map;
  import java.util.List;
  import java.lang.String;
  import java.util.Iterator;
  /**
   * Extended enumeration.
   *
   * @author Stephen Colebourne
   * @version $Id: Extended3Enum.java,v 1.1 2003/02/04 18:30:08 scolebourne Exp $
   */
  public class Extended3Enum extends Extended2Enum {
      public static final Extended1Enum DELTA = new Extended3Enum("Delta");
  
      protected Extended3Enum(String name) {
          super(name);
      }
  
      public static Extended1Enum getEnum(String name) {
          return (Extended1Enum) Enum.getEnum(Extended3Enum.class, name);
      }
  
      public static Map getEnumMap() {
          return Enum.getEnumMap(Extended3Enum.class);
      }
  
      public static List getEnumList() {
          return Enum.getEnumList(Extended3Enum.class);
      }
  
      public static Iterator iterator() {
          return Enum.iterator(Extended3Enum.class);
      }
  
  }
  
  
  1.1                  jakarta-commons/lang/src/test/org/apache/commons/lang/enum/Extended2Enum.java
  
  Index: Extended2Enum.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.lang.enum;
  
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  /**
   * Extended enumeration.
   *
   * @author Stephen Colebourne
   * @version $Id: Extended2Enum.java,v 1.1 2003/02/04 18:30:08 scolebourne Exp $
   */
  public class Extended2Enum extends Extended1Enum {
      public static final Extended1Enum GAMMA = new Extended2Enum("Gamma");
  
      protected Extended2Enum(String color) {
          super(color);
      }
  
      public static Extended1Enum getEnum(String name) {
          return (Extended1Enum) getEnum(Extended2Enum.class, name);
      }
  
      public static Map getEnumMap() {
          return getEnumMap(Extended2Enum.class);
      }
  
      public static List getEnumList() {
          return getEnumList(Extended2Enum.class);
      }
  
      public static Iterator iterator() {
          return iterator(Extended2Enum.class);
      }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message