Class MockValueBuilder

java.lang.Object
org.apache.camel.component.mock.MockValueBuilder
All Implemented Interfaces:
org.apache.camel.Expression, org.apache.camel.Predicate
Direct Known Subclasses:
AssertionClause.PredicateValueBuilder

public class MockValueBuilder extends Object implements org.apache.camel.Expression, org.apache.camel.Predicate
A builder of expressions or predicates based on values.

This implementation is a derived copy of the org.apache.camel.builder.ValueBuilder from camel-core, that are specialized for being used with the mock component and separated from camel-core.

  • Constructor Details

    • MockValueBuilder

      public MockValueBuilder(org.apache.camel.Expression expression)
  • Method Details

    • init

      public void init(org.apache.camel.CamelContext context)
      Specified by:
      init in interface org.apache.camel.Expression
      Specified by:
      init in interface org.apache.camel.Predicate
    • evaluate

      public <T> T evaluate(org.apache.camel.Exchange exchange, Class<T> type)
      Specified by:
      evaluate in interface org.apache.camel.Expression
    • matches

      public boolean matches(org.apache.camel.Exchange exchange)
      Specified by:
      matches in interface org.apache.camel.Predicate
    • getExpression

      public org.apache.camel.Expression getExpression()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • matches

      public org.apache.camel.Predicate matches(org.apache.camel.Expression expression)
    • matches

      public MockExpressionClause<org.apache.camel.Predicate> matches()
    • isTrue

      public org.apache.camel.Predicate isTrue()
    • isFalse

      public org.apache.camel.Predicate isFalse()
    • isNotEqualTo

      public org.apache.camel.Predicate isNotEqualTo(Object value)
    • isEqualTo

      public org.apache.camel.Predicate isEqualTo(Object value)
    • isEqualToIgnoreCase

      public org.apache.camel.Predicate isEqualToIgnoreCase(Object value)
    • isLessThan

      public org.apache.camel.Predicate isLessThan(Object value)
    • isLessThanOrEqualTo

      public org.apache.camel.Predicate isLessThanOrEqualTo(Object value)
    • isGreaterThan

      public org.apache.camel.Predicate isGreaterThan(Object value)
    • isGreaterThanOrEqualTo

      public org.apache.camel.Predicate isGreaterThanOrEqualTo(Object value)
    • isInstanceOf

      public org.apache.camel.Predicate isInstanceOf(Class<?> type)
    • isNull

      public org.apache.camel.Predicate isNull()
    • isNotNull

      public org.apache.camel.Predicate isNotNull()
    • not

      public org.apache.camel.Predicate not(org.apache.camel.Predicate predicate)
    • in

      public org.apache.camel.Predicate in(Object... values)
    • in

      public org.apache.camel.Predicate in(org.apache.camel.Predicate... predicates)
    • startsWith

      public org.apache.camel.Predicate startsWith(Object value)
    • endsWith

      public org.apache.camel.Predicate endsWith(Object value)
    • contains

      public org.apache.camel.Predicate contains(Object value)
      Create a predicate that the left-hand expression contains the value of the right-hand expression
      Parameters:
      value - the element which is compared to be contained within this expression
      Returns:
      a predicate which evaluates to true if the given value expression is contained within this expression value
    • regex

      public org.apache.camel.Predicate regex(String regex)
      Creates a predicate which is true if this expression matches the given regular expression
      Parameters:
      regex - the regular expression to match
      Returns:
      a predicate which evaluates to true if the expression matches the regex
    • expression

      public MockValueBuilder expression(Function<Object,Object> function)
      Creates an expression using the custom expression
      Parameters:
      function - the custom function
      Returns:
      a builder with the expression
    • language

      public MockValueBuilder language(String language, String value)
      Creates an expression using the given language
      Parameters:
      language - the language
      value - the expression value
      Returns:
      a builder with the expression
    • simple

      public MockValueBuilder simple(String value)
      Creates an expression using the simple language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • datasonnet

      public MockValueBuilder datasonnet(String value)
      Creates an expression using the datasonnet language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • groovy

      public MockValueBuilder groovy(String value)
      Creates an expression using the groovy language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • js

      public MockValueBuilder js(String value)
      Creates an expression using the javascript language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • jq

      public MockValueBuilder jq(String value)
      Creates an expression using the jq language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • jsonpath

      public MockValueBuilder jsonpath(String value)
      Creates an expression using the jsonpath language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • mvel

      public MockValueBuilder mvel(String value)
      Creates an expression using the mvel language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • ognl

      public MockValueBuilder ognl(String value)
      Creates an expression using the ognl language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • python

      public MockValueBuilder python(String value)
      Creates an expression using the python language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • spel

      public MockValueBuilder spel(String value)
      Creates an expression using the spel language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • xpath

      public MockValueBuilder xpath(String value)
      Creates an expression using the xpath language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • xquery

      public MockValueBuilder xquery(String value)
      Creates an expression using the xquery language
      Parameters:
      value - the expression value
      Returns:
      a builder with the expression
    • tokenize

      public MockValueBuilder tokenize()
      Creates an expression using the tokenize language using new-line as tokenizer
      Returns:
      a builder with the expression
    • tokenize

      public MockValueBuilder tokenize(String token)
      Creates an expression using the tokenize language
      Parameters:
      token - the token to use
      Returns:
      a builder with the expression
    • tokenize

      public MockValueBuilder tokenize(String token, int group, boolean skipFirst)
      Creates an expression using the tokenize language
      Parameters:
      token - the token to use
      group - number of elements to group
      skipFirst - whether to skip first element
      Returns:
      a builder with the expression
    • tokenize

      public MockValueBuilder tokenize(String token, String group, boolean skipFirst)
      Creates an expression using the tokenize language
      Parameters:
      token - the token to use
      group - number of elements to group
      skipFirst - whether to skip first element
      Returns:
      a builder with the expression
    • regexTokenize

      public MockValueBuilder regexTokenize(String regex)
      Tokenizes the string conversion of this expression using the given regular expression
    • regexReplaceAll

      public MockValueBuilder regexReplaceAll(String regex, String replacement)
      Replaces all occurrences of the regular expression with the given replacement
    • regexReplaceAll

      public MockValueBuilder regexReplaceAll(String regex, org.apache.camel.Expression replacement)
      Replaces all occurrences of the regular expression with the given replacement
    • convertTo

      public MockValueBuilder convertTo(Class<?> type)
      Converts the current value to the given type using the registered type converters
      Parameters:
      type - the type to convert the value to
      Returns:
      the current builder
    • convertToString

      public MockValueBuilder convertToString()
      Converts the current value to a String using the registered type converters
      Returns:
      the current builder
    • append

      public MockValueBuilder append(Object value)
      Appends the string evaluation of this expression with the given value
      Parameters:
      value - the value or expression to append
      Returns:
      the current builder
    • prepend

      public MockValueBuilder prepend(Object value)
      Prepends the string evaluation of this expression with the given value
      Parameters:
      value - the value or expression to prepend
      Returns:
      the current builder
    • sort

      public MockValueBuilder sort(Comparator<?> comparator)
      Sorts the current value using the given comparator. The current value must be convertable to a List to allow sorting using the comparator.
      Parameters:
      comparator - the comparator used by sorting
      Returns:
      the current builder
    • not

      public MockValueBuilder not()
      Negates the built expression.
      Returns:
      the current builder
    • onNewPredicate

      protected org.apache.camel.Predicate onNewPredicate(org.apache.camel.Predicate predicate)
      A strategy method to allow derived classes to deal with the newly created predicate in different ways
    • asExpression

      protected org.apache.camel.Expression asExpression(Object value)
    • onNewValueBuilder

      protected MockValueBuilder onNewValueBuilder(org.apache.camel.Expression exp)