Enum Class CollectionOperator
- All Implemented Interfaces:
Serializable,Comparable<CollectionOperator>,Constable
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)
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionbooleanwhen the result for the first item in the collection is calculated, there isn't yet a collated result to use in thereduce(boolean, boolean)method.abstract booleanreduce(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 booleanshortCircuit(boolean collatedResult) This method lets the engine know if it can short circuit its iteration through the list based on the collated result.static CollectionOperatorReturns the enum constant of this class with the specified name.static CollectionOperator[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ONE_OR_MORE
-
ALL
-
NONE
-
-
Method Details
-
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
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 nameNullPointerException- 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 thereduce(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.
-