This examples illustrates that your logic is a combination of Reactive Programming Rules, and JavaScript.

Note your JavaScript can use LIbraries of Java/JavaScript code.  Upload these to your project in Project properties.