Class LookupExpression

java.lang.Object
li.selman.jpbe.dsl.expression.LookupExpression
All Implemented Interfaces:
DslElement, Expression

public class LookupExpression extends Object implements Expression
Note that not the whole input string has to match for the lookup expression to be applied. For example, if we have a lookup table that translates from German to French numbers, the following input: "einsAAAA, zwei, dreissig" would translate to "uneAAAA, doix, troisssig".

Note that if you want a stricter behaviour, i.e. the whole string must match, you can implement your own LookupExpression and LookupExpressionBuilder.

See Also:
  • Constructor Details

    • LookupExpression

      public LookupExpression(Map<String,String> lookupTable)
  • Method Details

    • apply

      public Optional<String> apply(String input)
      Specified by:
      apply in interface Expression
    • getDslWeight

      public int getDslWeight()
      Description copied from interface: DslElement
      The weight can be used to find an optimal program in a set of valid programs. "Optimal" is subjective and can go into different directions. Some examples include:
      • Weight by how expensive a DSL element is to execute.
        Weight by how likely a DSL element is to be part of a generic full program. A ConstantPosition generally is less generic. Thus, the user has to specify their intent more often to finish their wrangling task.
    • Specified by:
      getDslWeight in interface DslElement
      Returns:
      the weight of the DSL element
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object