Enum Class CollectionOperator

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

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<T> item : comparableItems) {
     collatedResult = collectionOper.reduce(compare(item, compareValue), collatedResult);
     if (collectionOper.shortCircuit(collatedResult)) break;
 }
 
Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Enum Constant Details

  • Method Details

    • values

      public static CollectionOperator[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CollectionOperator valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class 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.