Class CascadeDecoder

java.lang.Object
org.smartparam.engine.core.decoder.StandardDecoder
pl.decerto.hyperon.runtime.decoder.CascadeDecoder
All Implemented Interfaces:
ValueDecoder

public class CascadeDecoder extends StandardDecoder
Decoder that is used internally to decode and call Higson parameters and functions.
Author:
przemek hertel
  • Constructor Details

    • CascadeDecoder

      public CascadeDecoder(HyperonEngine engine)
      defauld cascade constructor
      Parameters:
      engine - Implementation of HyperonEngine that is used to call decoded parameters and functions
  • Method Details

    • decode

      public ValueHolder decode(String text, Type<?> type, ParamContext ctx)
      decodes given text to specific ValueHolder. If text contains special prefixes $f or $p then function/parameter code is extracted from text and called using HyperonEngine. If text does NOT contain special prefixes, then decoding is passed to StandardDecoder.decode(String, Type, ParamContext)
      Specified by:
      decode in interface ValueDecoder
      Overrides:
      decode in class StandardDecoder
      Parameters:
      text - contains value to decode, for example:
      • simple text
      • 1234
      • 2018-01-15 09:10:11
      • $f hyperon.test.function
      • $p hyperon.test.param
      type - implementation of Type that will be used to convert result of parameter/function (if text contains special prefixes $f or $p) or simple value from text argument
      ctx - implementation of ParamContext that is passed to parameter/function invocation
      Returns:
      specific implementation of ValueHolder containing decoded value
      See Also:
    • cascadeCall

      public Object cascadeCall(String functionCode, ParamContext ctx)
      calls function using HyperonEngine that was passed in constructor
      Parameters:
      functionCode - cascade function code (without $f) that will be called. Code examples:
      • hyperon.example.fun
      • hyperon.example.fun(1, 2)
      • hyperon.example.fun(ctx:policy.insurer.age, 7)
      ctx - implementation of ParamContext that is passed to function invocation
      Returns:
      raw result of function invocation
      See Also:
    • cascadeCall

      public Object cascadeCall(String functionCode, Type<?> type, ParamContext ctx)
      calls function using HyperonEngine that was passed in constructor. If function result is a simple type then it is converted to specific ValueHolder from passed type
      Parameters:
      functionCode - cascade function code (without $f) that will be called. Code examples:
      • hyperon.example.fun
      • hyperon.example.fun(1, 2)
      • hyperon.example.fun(ctx:policy.insurer.age, 7)
      type - implementation of Type that will be used to convert function result if returned object is simple type
      ctx - implementation of ParamContext that is passed to function invocation
      Returns:
      converted result of function invocation, if function returns simple value, raw function result otherwise
      See Also:
    • cascadeGet

      public ValueHolder cascadeGet(String parameterCode, Type<?> type, ParamContext ctx)
      invokes parameter using HyperonEngine that was passed in constructor. If parameter result is a simple type then it is converted to specific ValueHolder from passed type
      Parameters:
      parameterCode - cascade parameter code (without $p) that will be invoked. Code examples:
      • hyperon.example.param
      • hyperon.example.param[1]
      • hyperon.example.param[factor]
      type - implementation of Type that will be used to convert parameter result if returned object is simple type
      ctx - implementation of ParamContext that is passed to parameter invocation
      Returns:
      converted result of parameter invocation, if parameter returns simple value, raw parameter result otherwise
      See Also:
    • cascadeGet

      public ValueHolder[] cascadeGet(String parameterCode, ParamContext ctx)
      invokes parameter using HyperonEngine that was passed in constructor
      Parameters:
      parameterCode - cascade parameter code (without $p) that will be invoked. Code examples:
      • hyperon.example.param
      • hyperon.example.param[1]
      • hyperon.example.param[factor]
      ctx - implementation of ParamContext that is passed to parameter invocation
      Returns:
      instance of ValueHolder
      See Also:
    • cascadeGetMultiValues

      public MultiValue[] cascadeGetMultiValues(String parameterCode, ParamContext ctx)
      invokes parameter using HyperonEngine that was passed in constructor
      Parameters:
      parameterCode - cascade parameter code (without $p) that will be invoked. Code examples:
      • hyperon.example.param
      • hyperon.example.param[1]
      • hyperon.example.param[factor]
      ctx - implementation of ParamContext that is passed to parameter invocation
      Returns:
      instance of MultiValue
      See Also: