Class ContainerIterators.ClosureIteratorEvaluator
- java.lang.Object
-
- net.ssehub.easy.varModel.cstEvaluation.ContainerIterators.CollectingIteratorEvaluator
-
- net.ssehub.easy.varModel.cstEvaluation.ContainerIterators.ClosureIteratorEvaluator
-
- All Implemented Interfaces:
IIteratorEvaluator
- Enclosing class:
- ContainerIterators
private static class ContainerIterators.ClosureIteratorEvaluator extends ContainerIterators.CollectingIteratorEvaluator
Implements a basic closure iterator which can stop on a cycle. UsesContainerIterators.DATA_CLOSURE_MARKEDandContainerIterators.DATA_CLOSURE_CYCLIC.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private booleanstopOnCycle
-
Constructor Summary
Constructors Modifier Constructor Description privateClosureIteratorEvaluator(boolean stopOnCycle)Creates the closure iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Valueaggregate(EvaluationAccessor result, Value iter, EvaluationAccessor value, java.util.Map<java.lang.Object,java.lang.Object> data)Aggregatevaluetoresult.private booleanhandleNextValue(Value value, ContainerValue result, java.util.Map<java.lang.Object,java.lang.Object> data, java.util.List<Value> nextValues)Handles the next value by checking whether it was already added.private voidhandleResult(boolean changed, EvaluationAccessor result, EvaluationAccessor value, int index)Handles the bound container elements ofresult.protected booleanhasCycle(java.util.Map<java.lang.Object,java.lang.Object> data)Returns whether a cycle was detected.-
Methods inherited from class net.ssehub.easy.varModel.cstEvaluation.ContainerIterators.CollectingIteratorEvaluator
getStartResult, postProcessResult
-
-
-
-
Method Detail
-
aggregate
public Value aggregate(EvaluationAccessor result, Value iter, EvaluationAccessor value, java.util.Map<java.lang.Object,java.lang.Object> data) throws ValueDoesNotMatchTypeException
Description copied from interface:IIteratorEvaluatorAggregatevaluetoresult.- Parameters:
result- the aggregating resultiter- the current value of the iteratorvalue- the value to be aggregateddata- arbitrary data to be hold while actually evaluating the function- Returns:
- a boolean value to indicate whether iteration/evaluation shall stop (
trueif iteration shall stop due to this evaluation,falseelse), a collection of values as instance ofListWrapperValuewhere to go on - Throws:
ValueDoesNotMatchTypeException- in case of type compatibility problems
-
hasCycle
protected boolean hasCycle(java.util.Map<java.lang.Object,java.lang.Object> data)
Returns whether a cycle was detected.- Parameters:
data- the data object- Returns:
truefor cycle,falseelse
-
handleNextValue
private boolean handleNextValue(Value value, ContainerValue result, java.util.Map<java.lang.Object,java.lang.Object> data, java.util.List<Value> nextValues) throws ValueDoesNotMatchTypeException
Handles the next value by checking whether it was already added.- Parameters:
value- the valueresult- the result container to be changed if not already addeddata- the temporary data storing already added elementsnextValues- the next values to be considered for iteration- Returns:
trueifvaluewas added toresult,falseelse- Throws:
ValueDoesNotMatchTypeException- if addingvaluetoresultis failing
-
handleResult
private void handleResult(boolean changed, EvaluationAccessor result, EvaluationAccessor value, int index)Handles the bound container elements ofresult.- Parameters:
changed- whether the result container was changed by the last evaluationresult- the result accessor to be modifiedvalue- the value accessorindex- the index of the bound element, no index if negative
-
-