GithubHelp home page GithubHelp logo

business-rules's Introduction

Rule expression parsing library

This library parses business rules, and gives you valuable insights into the rule's composition like the no. of expressions, the business variables used it can also be used to edit the rule in a systematic way (instead of just string replace) A simple rule will be of the form:

( amount > 1000.00 )

Here the 'amount' is the business domain variable.
Rules can be defined for any domain as needed. You can write very complex rules with nested 'and' and 'or' conditions
example:
( ( ( trade-amount > 1000000) & (risk-ind = "Y" )) | (risk-ind = "N") )

The rule grammar is written as an ANTLR grammar, a .g4 file

Rule Transformation

Any given business rule can be transformed in to its eqivalent XML Comparing 2 rules as XML becomes easy using XMLUnit library

Rule String

ind=Y and amount = 1000000

XML Representation
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<business-rule expressionCount="2" variables="[amount, ind]">
  <binaryExpression depth="1" operator="and">
    <variableExpression depth="1" position="1" text="ind=Y"/>
    <NumberExpression depth="1" position="2" text="amount=1000000"/>
  </binaryExpression>
</business-rule>
How to convert ?
		String rule = "ind=Y or amount = 1000000";
		System.out.println("Input rule: " + rule);
		RuleToXMLCoverter conv = new RuleToXMLCoverter(rule);
		conv.parseRule();
		System.out.println(conv.getXmlString());

business-rules's People

Contributors

ssdimmanuel avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.