org.eclipse.ocl.examples.library.iterator
Class IterateIteration
java.lang.Object
org.eclipse.ocl.examples.domain.library.AbstractFeature
org.eclipse.ocl.examples.domain.library.AbstractIteration
org.eclipse.ocl.examples.library.iterator.IterateIteration
- All Implemented Interfaces:
- LibraryFeature, LibraryIteration
public class IterateIteration
- extends AbstractIteration
IterateIteration realizes the Collection::iterate() library iteration.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INSTANCE
public static final IterateIteration INSTANCE
IterateIteration
public IterateIteration()
createAccumulatorValue
public Value createAccumulatorValue(DomainEvaluator evaluator,
DomainType accumulatorType,
DomainType bodyType)
- Description copied from interface:
LibraryIteration
- Create the value that will accumulate the iteration results.
- Parameters:
evaluator
- that supervises evaluation
- Returns:
- the accumulator
evaluateIteration
public Value evaluateIteration(DomainIterationManager iterationManager)
throws InvalidValueException
- Description copied from class:
AbstractIteration
- The default iteration algorithm steps through the iteration domain by invoking
DomainIterationManager.hasCurrent()
and DomainIterationManager.advanceIterators()
.
At each step AbstractIteration.updateAccumulator(DomainIterationManager)
is invoked to update the
accumulator for that step. A non-null return causes a premature exit and forms the
return from the overall evaluation. If all steps complete AbstractIteration.resolveTerminalValue(DomainIterationManager)
is invoked to provide the return value.
Derived classes may override this method to change the iteration algorithm or override
the call-backs to customize the default iteration.
- Specified by:
evaluateIteration
in interface LibraryIteration
- Overrides:
evaluateIteration
in class AbstractIteration
- Parameters:
iterationManager
- the iteration space
- Returns:
- the result
- Throws:
InvalidValueException
- if a body evaluates to invalid
updateAccumulator
protected Value updateAccumulator(DomainIterationManager iterationManager)
- Description copied from class:
AbstractIteration
- Update the accumulatorValue with the bodyValue resulting from the current iteration
for which the iterators define the context in the environment.
- Specified by:
updateAccumulator
in class AbstractIteration
- Parameters:
iterationManager
- the iteration context
- Returns:
- non-null premature result of iteration, or null if complete