Class FormulaParser.Builder<T>

java.lang.Object
io.jenetics.ext.internal.util.FormulaParser.Builder<T>
Type Parameters:
T - the token type
Enclosing class:
FormulaParser<T>

public static final class FormulaParser.Builder<T> extends Object
Builder for building new FormulaParser instances.
  • Method Details

    • lparen

      public FormulaParser.Builder<T> lparen(Predicate<? super T> lparen)
      Set the predicate which defines lparen tokens. If the given predicate returns true for a token, it is treated as lparen.
      Parameters:
      lparen - the lparen token
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the lparen is null
    • lparen

      public FormulaParser.Builder<T> lparen(T lparen)
      Set the prototype for the lparen token. A given token is treated as lparen if Objects.equals(token, lparen) returns true.
      Parameters:
      lparen - the lparen prototype
      Returns:
      this builder, for method chaining
    • rparen

      public FormulaParser.Builder<T> rparen(Predicate<? super T> rparen)
      Set the predicate which defines rparen tokens. If the given predicate returns true for a token, it is treated as rparen.
      Parameters:
      rparen - the rparen token
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the rparen is null
    • rparen

      public FormulaParser.Builder<T> rparen(T rparen)
      Set the prototype for the rparen token. A given token is treated as rparen if Objects.equals(token, rparen) returns true.
      Parameters:
      rparen - the rparen prototype
      Returns:
      this builder, for method chaining
    • separator

      public FormulaParser.Builder<T> separator(Predicate<? super T> separator)
      Set the predicate which defines separator tokens. If the given predicate returns true for a token, it is treated as separator.
      Parameters:
      separator - the separator token
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the separator is null
    • separator

      public FormulaParser.Builder<T> separator(T separator)
      Set the prototype for the separator token. A given token is treated as separator if Objects.equals(token, separator) returns true.
      Parameters:
      separator - the separator prototype
      Returns:
      this builder, for method chaining
    • unaryOperators

      Set the predicate which defines the unary operator tokens. If the given predicate returns true for a token, it is treated as unary operator.
      Parameters:
      ops - the comma token
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the ops is null
    • unaryOperators

      public FormulaParser.Builder<T> unaryOperators(Set<? extends T> ops)
      Set all unary operator tokens.
      Parameters:
      ops - the unary operator tokens
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the ops is null
    • unaryOperators

      Set all unary operator tokens.
      Parameters:
      ops - the unary operator tokens
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the ops is null
    • binaryOperators

      public FormulaParser.Builder<T> binaryOperators(List<? extends Predicate<? super T>> ops)
      Set the list of predicates which defines the binary ops. The predicate indexes of the list represent the precedence of the binary ops. ops.get(0) has the lowest precedence and ops.get(ops.size() - 1) has the highest precedence
      Parameters:
      ops - the predicates defining the binary operator tokens
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the ops is null
    • binaryOperators

      Set the list of predicates which defines the binary ops. The predicate indexes of the list represent the precedence of the binary ops. ops.get(0) has the lowest precedence and ops.get(ops.size() - 1) has the highest precedence
      Parameters:
      ops - the predicates defining the binary operator tokens
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the ops is null
    • binaryOperators

      Method for defining the binary operators and its precedence.
      Parameters:
      ops - the predicates defining the binary operator tokens
      Returns:
      this builder, for method chaining
    • identifiers

      public FormulaParser.Builder<T> identifiers(Predicate<? super T> identifiers)
      Set the predicate which defines identifier tokens.
      Parameters:
      identifiers - the identifier predicate
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the identifiers is null
    • identifiers

      public FormulaParser.Builder<T> identifiers(Set<? extends T> identifiers)
      Set all identifier tokens.
      Parameters:
      identifiers - the identifier tokens
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the identifiers is null
    • identifiers

      @SafeVarargs public final FormulaParser.Builder<T> identifiers(T... identifiers)
      Set all identifier tokens.
      Parameters:
      identifiers - the identifier tokens
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the identifiers is null
    • functions

      public FormulaParser.Builder<T> functions(Predicate<? super T> functions)
      Set the predicate which defines function tokens.
      Parameters:
      functions - the function predicate
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the functions is null
    • functions

      public FormulaParser.Builder<T> functions(Set<? extends T> functions)
      Set all functions tokens.
      Parameters:
      functions - the function tokens
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the functions is null
    • functions

      @SafeVarargs public final FormulaParser.Builder<T> functions(T... functions)
      Set all functions tokens.
      Parameters:
      functions - the function tokens
      Returns:
      this builder, for method chaining
      Throws:
      NullPointerException - if the functions is null
    • build

      public FormulaParser<T> build()
      Create a new formula parser with the defined values.
      Returns:
      a new formula parser