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 (Comparableitem : comparableItems) { collatedResult = collectionOper.reduce(compare(item, compareValue), collatedResult); if (collectionOper.shortCircuit(collatedResult)) break; }
Enum Constant and Description |
---|
ALL |
NONE |
ONE_OR_MORE |
Modifier and Type | Method and Description |
---|---|
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.
|
public static final CollectionOperator ONE_OR_MORE
public static final CollectionOperator ALL
public static final CollectionOperator NONE
public static CollectionOperator[] values()
for (CollectionOperator c : CollectionOperator.values()) System.out.println(c);
public static CollectionOperator valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic abstract boolean reduce(boolean elementResult, boolean collatedResult)
public abstract boolean shortCircuit(boolean collatedResult)
collatedResult
- public boolean getInitialCollatedResult()
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-2015 The Kuali Foundation. All Rights Reserved.