org.apache.avalon.framework
Class ValuedEnum

java.lang.Object
  |
  +--org.apache.avalon.framework.Enum
        |
        +--org.apache.avalon.framework.ValuedEnum

public abstract class ValuedEnum
extends Enum

Basic enum class for type-safe enums with values. Should be used as an abstract base.

Author:
Peter Donald

Constructor Summary
ValuedEnum(java.lang.String name, int value)
          Constructor for enum.
ValuedEnum(java.lang.String name, int value, java.util.Map map)
          Constructor for enum so that it gets added to map at creation.
 
Method Summary
 int getValue()
          Get value of enum.
 boolean isEqualTo(ValuedEnum other)
          Test if enum is equal in value to other enum.
 boolean isGreaterThan(ValuedEnum other)
          Test if enum is greater than in value to other enum.
 boolean isGreaterThanOrEqual(ValuedEnum other)
          Test if enum is greater than or equal in value to other enum.
 boolean isLessThan(ValuedEnum other)
          Test if enum is less than in value to other enum.
 boolean isLessThanOrEqual(ValuedEnum other)
          Test if enum is less than or equal in value to other enum.
 java.lang.String toString()
          Overide toString method to produce human readable description.
 
Methods inherited from class org.apache.avalon.framework.Enum
getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ValuedEnum

public ValuedEnum(java.lang.String name,
                  int value,
                  java.util.Map map)
Constructor for enum so that it gets added to map at creation. Adding to a map is useful for implementing find...() style methods.
Parameters:
name - the name of enum
value - the value of enum
map - the map to add enum to

ValuedEnum

public ValuedEnum(java.lang.String name,
                  int value)
Constructor for enum.
Parameters:
name - the name of enum
value - the value of enum
Method Detail

getValue

public final int getValue()
Get value of enum.
Returns:
the enums value

isEqualTo

public final boolean isEqualTo(ValuedEnum other)
Test if enum is equal in value to other enum.
Parameters:
other - the other enum
Returns:
true if equal

isGreaterThan

public final boolean isGreaterThan(ValuedEnum other)
Test if enum is greater than in value to other enum.
Parameters:
other - the other enum
Returns:
true if greater than

isGreaterThanOrEqual

public final boolean isGreaterThanOrEqual(ValuedEnum other)
Test if enum is greater than or equal in value to other enum.
Parameters:
other - the other enum
Returns:
true if greater than or equal

isLessThan

public final boolean isLessThan(ValuedEnum other)
Test if enum is less than in value to other enum.
Parameters:
other - the other enum
Returns:
true if less than

isLessThanOrEqual

public final boolean isLessThanOrEqual(ValuedEnum other)
Test if enum is less than or equal in value to other enum.
Parameters:
other - the other enum
Returns:
true if less than or equal

toString

public java.lang.String toString()
Overide toString method to produce human readable description.
Overrides:
toString in class Enum
Returns:
human readable description of enum


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.