org.sape.carbon.core.util.enum
Class EnumMask

java.lang.Object
  |
  +--org.sape.carbon.core.util.enum.EnumMask

public class EnumMask
extends Object

This class provides the functionality for searching sets of Enumerations. This allows for construction of this EnumMask with a statically defined array of Enum objects and then searching to see if one of the values is contained.

This class can be used like the following.

 ...
 private static final EnumMask GOOD_STATES =
     new EnumMask(new BaseEnum[] { StatesEnum.INDIANA,
                                   StatesEnum.IOWA,
                                   StatesEnum.IDAHO,
                                   StatesEnum.ILLINOIS });

 public boolean isGoodState(StatesEnum state) {
     return GOOD_STATES.contains(state);
 }
 ...
 

Copyright 2002 Sapient

Since:
carbon 1.0
Version:
$Revision: 1.6 $($Author: dvoet $ / $Date: 2003/05/05 21:21:22 $)
Author:
Greg Hinkle, January 2002

Field Summary
private  Set enums
          The enums set that contains this mask
 
Constructor Summary
EnumMask(BaseEnum[] keys)
          Constructs a Mask object from the provided array of Enums.
 
Method Summary
 boolean contains(BaseEnum enum)
          Checks to see if the enum exists in this mask.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

enums

private Set enums
The enums set that contains this mask

Constructor Detail

EnumMask

public EnumMask(BaseEnum[] keys)

Constructs a Mask object from the provided array of Enums.

Parameters:
keys - The set of Enums that will be the Mask
Method Detail

contains

public boolean contains(BaseEnum enum)

Checks to see if the enum exists in this mask.

Parameters:
enum - The enum to check for
Returns:
true if the supplied enum is in the mask and false otherwise


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.