Class NMatchOperation
java.lang.Object
org.eclipse.epsilon.eol.execute.operations.AbstractOperation
org.eclipse.epsilon.eol.execute.operations.declarative.FirstOrderOperation
org.eclipse.epsilon.eol.execute.operations.declarative.NMatchOperation
- Direct Known Subclasses:
ParallelNMatchOperation
Operation based on whether n elements satisfy the predicate.
The semantics are defined by
NMatchOperation.MatchMode. n can be user-defined
or specified once for this short-circuiting operation.- Since:
- 1.6
- Author:
- Sina Madani
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDetermines the interpretation of n.NMatchOperation.MatchMode.EXACT: Whether the number of elements satisfying the predicate is equal to n,
NMatchOperation.MatchMode.MINIMUM: Whether the number of elements satisfying the predicate is greater than or equal to n,
NMatchOperation.MatchMode.MAXIMUM: Whether the number of elements satisfying the predicate is less than or equal to n. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNMatchOperation(NMatchOperation.MatchMode behaviour) nMatch operation where target matches is specified on a per-invocation basis.NMatchOperation(NMatchOperation.MatchMode behaviour, int n) nMatch operation with the target matches pre-specified. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleandetermineResult(int currentMatches, int targetMatches) protected booleanexecute(int sourceSize, int targetMatches, Collection<Object> source, NameExpression operationNameExpression, List<Parameter> iterators, Expression expression, IEolContext context) final Booleanexecute(Object target, NameExpression operationNameExpression, List<Parameter> iterators, List<Expression> expressions, IEolContext context) protected booleanshouldShortCircuit(int sourceSize, int targetMatches, int currentMatches, int currentIndex) Methods inherited from class org.eclipse.epsilon.eol.execute.operations.declarative.FirstOrderOperation
createIteratorVariable, execute, resolve, resolveFunction, resolvePredicate, resolveSourceMethods inherited from class org.eclipse.epsilon.eol.execute.operations.AbstractOperation
isOverridable, toString
-
Field Details
-
mode
-
-
Constructor Details
-
NMatchOperation
nMatch operation where target matches is specified on a per-invocation basis. -
NMatchOperation
nMatch operation with the target matches pre-specified.- Parameters:
behaviour- How to interpret what n means.n- The number of target matches.- Throws:
IllegalArgumentException- If n is less than zero.
-
-
Method Details
-
execute
public final Boolean execute(Object target, NameExpression operationNameExpression, List<Parameter> iterators, List<Expression> expressions, IEolContext context) throws EolRuntimeException - Overrides:
executein classFirstOrderOperation- Throws:
EolRuntimeException
-
shouldShortCircuit
protected boolean shouldShortCircuit(int sourceSize, int targetMatches, int currentMatches, int currentIndex) -
determineResult
protected boolean determineResult(int currentMatches, int targetMatches) -
execute
protected boolean execute(int sourceSize, int targetMatches, Collection<Object> source, NameExpression operationNameExpression, List<Parameter> iterators, Expression expression, IEolContext context) throws EolRuntimeException - Throws:
EolRuntimeException
-