gov.sandia.cognition.evaluator
Class CompositeEvaluatorList<InputType,OutputType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.evaluator.CompositeEvaluatorList<InputType,OutputType>
Type Parameters:
InputType - The input type of the first evaluator of the list, which is also the input type of the composite evaluator.
OutputType - The output type of the last evaluator of the list, which is also the output type of the composite evaluator.
All Implemented Interfaces:
Evaluator<InputType,OutputType>, CloneableSerializable, Serializable, Cloneable

public class CompositeEvaluatorList<InputType,OutputType>
extends AbstractCloneableSerializable
implements Evaluator<InputType,OutputType>

Implements the composition of a list of evaluators. The input is passed to the first evaluator, whose output is passed to the next, which continues down the list until the output of the last evaluator is returned. If the evaluators in the list are f1, f2, ..., fN, and the input is x, the result of the composition is fN(...(f2(f1(x)))...).

Since:
2.1
Author:
Justin Basilico
See Also:
Serialized Form

Constructor Summary
CompositeEvaluatorList()
          Creates a new CompositeEvaluatorList with an empty list of evaluators.
CompositeEvaluatorList(Collection<? extends Evaluator<?,?>> evaluators)
          Creates a new CompositeEvaluatorList from the given collection of evaluators.
CompositeEvaluatorList(Evaluator<?,?>... evaluatorsArray)
          Creates a new CompositeEvaluatorList from the given array of evaluators.
 
Method Summary
 CompositeEvaluatorList<InputType,OutputType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 OutputType evaluate(InputType input)
          Evaluates the function on the given input and returns the output.
 ArrayList<Evaluator<?,?>> getEvaluators()
          Gets the list of evaluators that is being composed together.
 void setEvaluators(Collection<? extends Evaluator<?,?>> evaluators)
          Sets the list of evaluators to compose together.
 void setEvaluators(Evaluator<?,?>... evaluatorsArray)
          Sets the array of evaluators to compose together.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeEvaluatorList

public CompositeEvaluatorList()
Creates a new CompositeEvaluatorList with an empty list of evaluators.


CompositeEvaluatorList

public CompositeEvaluatorList(Evaluator<?,?>... evaluatorsArray)
Creates a new CompositeEvaluatorList from the given array of evaluators.

Parameters:
evaluatorsArray - The array of evaluators to compose.

CompositeEvaluatorList

public CompositeEvaluatorList(Collection<? extends Evaluator<?,?>> evaluators)
Creates a new CompositeEvaluatorList from the given collection of evaluators. It makes a copy of the given collection.

Parameters:
evaluators - The evaluators to compose.
Method Detail

clone

public CompositeEvaluatorList<InputType,OutputType> clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

evaluate

public OutputType evaluate(InputType input)
Description copied from interface: Evaluator
Evaluates the function on the given input and returns the output.

Specified by:
evaluate in interface Evaluator<InputType,OutputType>
Parameters:
input - The input to evaluate.
Returns:
The output produced by evaluating the input.

getEvaluators

public ArrayList<Evaluator<?,?>> getEvaluators()
Gets the list of evaluators that is being composed together.

Returns:
The list of evaluators.

setEvaluators

public void setEvaluators(Collection<? extends Evaluator<?,?>> evaluators)
Sets the list of evaluators to compose together. The given collection is copied.

Parameters:
evaluators - The list of evaluators.

setEvaluators

public void setEvaluators(Evaluator<?,?>... evaluatorsArray)
Sets the array of evaluators to compose together.

Parameters:
evaluatorsArray - The array of evaluators.