org.kuali.rice.krms.framework.engine
Enum CollectionOperator

java.lang.Object
  extended by java.lang.Enum<CollectionOperator>
      extended by org.kuali.rice.krms.framework.engine.CollectionOperator
All Implemented Interfaces:
Serializable, Comparable<CollectionOperator>

public enum CollectionOperator
extends Enum<CollectionOperator>

Enumeration for simple collection operators used by CollectionOfComparablesTermBasedProposition. The operators encapsulate logic for how to collate results and when to short circuit as a collection is being processed. Correct usage is best summarized by this code block:

 for (Comparable item : comparableItems) {
     collatedResult = collectionOper.reduce(compare(item, compareValue), collatedResult);
     if (collectionOper.shortCircuit(collatedResult)) break;
 }
 

Author:
Kuali Rice Team (rice.collab@kuali.org)

Enum Constant Summary
ALL
           
NONE
           
ONE_OR_MORE
           
 
Method Summary
 boolean getInitialCollatedResult()
          when the result for the first item in the collection is calculated, there isn't yet a collated result to use in the reduce(boolean, boolean) method.
abstract  boolean reduce(boolean elementResult, boolean collatedResult)
          This method takes the collated result thus far and the result for the next element, and produces the next collated result.
abstract  boolean shortCircuit(boolean collatedResult)
          This method lets the engine know if it can short circuit its iteration through the list based on the collated result.
static CollectionOperator valueOf(String name)
          Returns the enum constant of this type with the specified name.
static CollectionOperator[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

ONE_OR_MORE

public static final CollectionOperator ONE_OR_MORE

ALL

public static final CollectionOperator ALL

NONE

public static final CollectionOperator NONE
Method Detail

values

public static CollectionOperator[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (CollectionOperator c : CollectionOperator.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static CollectionOperator valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

reduce

public abstract boolean reduce(boolean elementResult,
                               boolean collatedResult)
This method takes the collated result thus far and the result for the next element, and produces the next collated result.

Returns:
the new collated result

shortCircuit

public abstract boolean shortCircuit(boolean collatedResult)
This method lets the engine know if it can short circuit its iteration through the list based on the collated result. The condition when short circuiting can be done varies with the operator.

Parameters:
collatedResult -
Returns:
true if short circuiting can be done to optimize processing

getInitialCollatedResult

public boolean getInitialCollatedResult()
when the result for the first item in the collection is calculated, there isn't yet a collated result to use in the reduce(boolean, boolean) method. Different operators require different initial values to function correctly, so this property holds the correct initial collated value for the given operator instance.



Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.