Flow.apex

  • Docs
  • Tutorials
Docs Menu
  • Flows
  • Flow Methods
    • Creation Methods
    • Function Methods
    • Block Methods
    • Static Methods
  • FlowScript

Static Methods Guide

Static Methods

this Placeholder

Flow.apex has a placeholder for the current Flow, and it is Flow.self.

Flow f = new Flow()
     .inputAs('n').returnInteger()
     .doIf(
         Flow.call(R.equals.apply(0), Flow.getVar('n')),
         Flow.block()
             .doReturn(0)
     )
     .var('ret', Flow.call(R.add.apply(2), Flow.call(Flow.self, Flow.call(R.dec, Flow.getVar('n')))))
     .doReturn(Flow.getVar('ret'));

FlowScript Interpretation

Using Flow.s(String), we can convert Strings into Flow.apex invocations.

Flow f = new Flow()
    var('n', Flow.s('i'));

FlowScript Evaluation

We can evaluate the FlowScript independently from Flows.

Object result = Flow.eval('add(1, 2)');

FlowScript Evaluation

We can evaluate the FlowScript independently from Flows.

Object result = Flow.eval('add(1, 2)');
MethodDescription
eval(String)Evaluate without context
eval(String, Map)Evaluate with context

Block Creation

We can create a block like this:

Block b = Flow.block();

Get Variable

This is how we get the variable value.

Flow f = new Flow()
    .var('n', Flow.getVar('a'));
// Get the value of 'a' and set it to 'n'

Call Functions

This is how we call functions.

Flow f = new Flow()
    .var('ret', Flow.call(R.constant.apply('a')));
// Set value 'a' to 'ret', by calling a 'constant' Func that always returns the value it has received
MethodDescription
call(Func)Call the Func with no arguments
call(Func, Object)Call the Func with one argument
call(Func, Object, Object)Call the Func with two arguments
call(Func, Object, Object)Call the Func with three arguments
call(Func, List)Call the Func with a list of arguments

Add Custom Funcs

We can add custom Funcs like this:

Flow.addFuncs(new Map{ 'plus' => R.add });

Flow f = new Flow()
    .doReturn('plus(1, 2)');
MethodDescription
addFuncs(Map)Add a map of Funcs
addFunc(String, Func)Add Func with the name
removeAllFuncs()Remove all the Funcs

Contribute on Github! Edit this section.