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
public class NMatchOperation extends FirstOrderOperation
Operation based on whether n elements satisfy the predicate. The semantics are defined byNMatchOperation.MatchMode
. n can be user-defined or specified once for this short-circuiting operation.- Since:
- 1.6
- Author:
- Sina Madani
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NMatchOperation.MatchMode
Determines 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 Modifier and Type Field Description protected NMatchOperation.MatchMode
mode
-
Constructor Summary
Constructors Constructor Description NMatchOperation(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
determineResult(int currentMatches, int targetMatches)
protected boolean
execute(int sourceSize, int targetMatches, java.util.Collection<java.lang.Object> source, NameExpression operationNameExpression, java.util.List<Parameter> iterators, Expression expression, IEolContext context)
java.lang.Boolean
execute(java.lang.Object target, NameExpression operationNameExpression, java.util.List<Parameter> iterators, java.util.List<Expression> expressions, IEolContext context)
protected boolean
shouldShortCircuit(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, resolveSource
-
Methods inherited from class org.eclipse.epsilon.eol.execute.operations.AbstractOperation
isOverridable, toString
-
-
-
-
Field Detail
-
mode
protected final NMatchOperation.MatchMode mode
-
-
Constructor Detail
-
NMatchOperation
public NMatchOperation(NMatchOperation.MatchMode behaviour)
nMatch operation where target matches is specified on a per-invocation basis.
-
NMatchOperation
public NMatchOperation(NMatchOperation.MatchMode behaviour, int n) throws java.lang.IllegalArgumentException
nMatch operation with the target matches pre-specified.- Parameters:
behaviour
- How to interpret what n means.n
- The number of target matches.- Throws:
java.lang.IllegalArgumentException
- If n is less than zero.
-
-
Method Detail
-
execute
public final java.lang.Boolean execute(java.lang.Object target, NameExpression operationNameExpression, java.util.List<Parameter> iterators, java.util.List<Expression> expressions, IEolContext context) throws EolRuntimeException
- Overrides:
execute
in 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, java.util.Collection<java.lang.Object> source, NameExpression operationNameExpression, java.util.List<Parameter> iterators, Expression expression, IEolContext context) throws EolRuntimeException
- Throws:
EolRuntimeException
-
-