Comments (6)
Having an option where NEXT and BREAK don't have to be returned also allows for other (non procedural) rules chaining options. Although I think RuleBook will always have sequential chaining at its core, the focus has to be on an intuitive and flexible interface. That was the whole reason for RuleBook in the first place -> something that could be picked up and used effectively in an hour or two (at most).
from rulebook.
I also think that there should probably be an easier way to extract facts in the DSL. Using Fact objects is nice since it guarantees a reference - Facts hold references, and even do cool stuff like keep up with changes to immutable objects (e.g. Strings). But you shouldn't always have to know they are there or work directly with Fact objects or the FactMap object in the DSL. Modifying the given() is a great first step. But the next step is making Facts transparent in their usage in Rules.
What about something like the following?
StandardRule.create().given("hello", "Hello").given("world", "World").when(f -> true).using("hello").then(System.out::println).using("world").then(System.out::println); //this would print "HelloWorld"
or this would also work
StandardRule.create().given("hello", "Hello").given("world", "World").using("hello").then(System.out::println).using("hello").then(System.out::println); //this would print "HelloWorld"
or in a RuleBook (where Facts are automagically supplied to Rules)
StandardRule.create().using("hello").then(System.out::println).using("world").then(System.out::println); //this would print "HelloWorld"
from rulebook.
It looks like doing the above stuff will break the existing DSL, which I am not a huge fan of doing. But I do think it will yield a nicer to work with DSL and a more rich language.
This would not affect POJO rules, however.
from rulebook.
The DSL is mostly intact. All the old stuff will still work with one exception: then methods can't return anything. In lieu of having to return RuleState from a then method, the new stop method is introduced. By chaining the stop verb, it signals the rule to break the rule chain after the then action is executed, which also means the when condition must be true for the rule chain to be broken.
from rulebook.
Branch Issue36_SyntacticSugar contains the completed and working code. All tests are passing.
All that's left now to ensure that coverage is up to snuff given the new changes and JavaDocs are updated appropriately.
from rulebook.
These enhancements have been pushed out to 0.3.5-SNAPSHOT and merged into the develop branch.
from rulebook.
Related Issues (20)
- rule book runner incorrectly eats exceptions so buggy code is not caught. HOT 2
- Why withDefaultResult is mandatory? HOT 4
- How can i write dynamic rules to execute rather than writing in java program .like rules defined in JSON or Yaml? HOT 4
- Q: Rule as a singleton bean HOT 3
- Add the Supplier function to avoid the passage by reference for the default result HOT 2
- Should I fork? HOT 2
- using codegen to improving performance of rule execution HOT 1
- Rule name is dropping when build Rule withFactType. HOT 1
- How to write Unit Tests for a RuleBean? HOT 1
- Switch CI to GitHub Actions HOT 2
- Deprecated classes/methods and non-compiling examples in README.md HOT 1
- Auditor not set on rules when RuleBookBuilder.create(Class) is used HOT 2
- Futures/CompletionStage/Async HOT 2
- Fact checking before evaluating rules HOT 2
- Rulebook in Spring Boot - stop execution
- Project status HOT 2
- Lambdas stack error
- RuleBuilder doesn't create a Rule with action type RuleChainActionType.ERROR_ON_FAILURE HOT 2
- RuleBookRunner4PojoClasses does not run rules according to the order property
- Would need an update on how frequently this project is developed and actively supported HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rulebook.