InputType
- Input of the EvaluatorOutputType
- Output of the EvaluatorStateType
- State object contain in this@CodeReview(reviewer="Kevin R. Dixon",date="2008-02-08",changesNeeded=false,comments="Looks fine.") @CodeReview(reviewer="Justin Basilico",date="2007-11-20",changesNeeded=false,comments="Cleaned up.") public abstract class AbstractStatefulEvaluator<InputType,OutputType,StateType extends CloneableSerializable> extends AbstractCloneableSerializable implements StatefulEvaluator<InputType,OutputType,StateType>
AbstractStatefulEvalutor
class is an abstract implementation of
the StatefulEvalutor
interface. It provides a state object field plus
a getter and setter for the field plus an implementation of the method to
reset the state.StatefulEvaluator
,
Serialized FormConstructor and Description |
---|
AbstractStatefulEvaluator()
Creates a new instance of
AbstractStatefulEvaluator . |
AbstractStatefulEvaluator(StateType initialState)
Creates a new instance of
AbstractStatefulEvaluator . |
Modifier and Type | Method and Description |
---|---|
AbstractStatefulEvaluator<InputType,OutputType,StateType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
OutputType |
evaluate(InputType input,
StateType state)
Evaluates the object using the given input and the given state object,
returning the output.
|
StateType |
getState()
Gets the current state of the evaluator.
|
void |
resetState()
Resets the state of the evaluator to a default state.
|
void |
setState(StateType state)
Sets the current state of the evaluator.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createDefaultState, evaluate
public AbstractStatefulEvaluator()
AbstractStatefulEvaluator
.public AbstractStatefulEvaluator(StateType initialState)
AbstractStatefulEvaluator
.initialState
- The initial state object.public AbstractStatefulEvaluator<InputType,OutputType,StateType> clone()
AbstractCloneableSerializable
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.clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public OutputType evaluate(InputType input, StateType state)
StatefulEvaluator
evaluate
in interface StatefulEvaluator<InputType,OutputType,StateType extends CloneableSerializable>
input
- The input to evaluate.state
- The state to use, which can be modified by side effect.
The current state of the Evaluator will be based on this given
state.public StateType getState()
StatefulEvaluator
getState
in interface StatefulEvaluator<InputType,OutputType,StateType extends CloneableSerializable>
public void setState(StateType state)
StatefulEvaluator
createDefaultState()
or getState()
should be used for
proper behavior.setState
in interface StatefulEvaluator<InputType,OutputType,StateType extends CloneableSerializable>
state
- The new state for the evaluator.public void resetState()
StatefulEvaluator
resetState
in interface StatefulEvaluator<InputType,OutputType,StateType extends CloneableSerializable>