Interface IMatchExpression<T>

All Superinterfaces:
IExpression

public interface IMatchExpression<T> extends IExpression
A match expression is a boolean expression matching a candidate of a specific type. An IEvaluationContext is needed in order to evaluate a match and this class provides two ways of doing that. Either a context is created first and then reused in several subsequent calls to isMatch(IEvaluationContext, Object) or, if no repeated calls are expected, the isMatch(Object) method can be used. It will then create a context on each call.
Since:
2.0
  • Method Details

    • createContext

      IEvaluationContext createContext()

      Creates a new context to be passed to repeated subsequent evaluations. The context will introduce 'this' as an uninitialized variable and make the parameters available.

      Returns:
      A new evaluation context.
    • getParameters

      Object[] getParameters()
      Returns the parameters that this match expression was created with.
      Returns:
      An array of parameters, possibly empty but never null.
    • isMatch

      boolean isMatch(T candidate)
      This method creates a new evaluation context and assigns the candidate to the 'this' variable of the context and then evaluates the expression. This is essentially a short form for
      isMatch(createContext(), candidate)
      .
      Parameters:
      candidate - The object to test.
      Returns:
      the result of the evaluation.
    • isMatch

      boolean isMatch(IEvaluationContext context, T candidate)
      This method assigns candidate to the 'this' variable of the context and then evaluates the expression.
      Parameters:
      context - A context
      candidate - The object to test.
      Returns:
      the result of the evaluation.