Comments (4)
Maybe I misunderstood something, but I get an error
cannot find symbol
symbol: method addRule(com.deliveredtechnologies.rulebook.model.Rule<com.example.models.SomeClass,java.lang.String>)
location: class com.deliveredtechnologies.rulebook.lang.RuleBookWithResultTypeBuilder<java.lang.String>
when I try to compile this example without commenting out the line
RuleBook<String> rules = RuleBookBuilder.create()
.withResultType(String.class)
//.withDefaultResult("default")
.addRule(RuleBuilder.create(GoldenRule.class, RuleChainActionType.ERROR_ON_FAILURE)
.withFactType(SomeClass.class)
.withResultType(String.class)
.when(facts -> SomeState.FOO.equals(facts.getOne().getState()))
.then((facts, result) -> result.setValue("first"))
.stop()
.build())
.addRule(rule -> rule.withFactType(AnotherClass.class)
.when(facts -> AnotherState.BAR.equals(facts.getValue("another").getState()))
.then((facts, result) -> result.setValue("second")))
.build();
NameValueReferableMap<Object> facts = new FactMap<>();
facts.setValue("some", new SomeClass());
facts.setValue("another", new AnotherClass());
rules.run(facts);
I don't need the default. How to get rid of it?
from rulebook.
Yes, I want to have an empty Optional if no rules executed and no default defined, otherwise Optional of result or a default value if it was defined.
from rulebook.
withDefault is not mandatory. Having a result was always optional.
But if you do have a result and no rules are executed then you would get the default result if you had one.
Do you think it should behave differently?
from rulebook.
Ah, so if you have a result, then yes, you need to specify a default value. However, there is no requirement for you to have a result. So, perhaps it was I who misunderstood. But am I correct in understanding now that you want to have a result, but no default result?
Presently, that is not something that's possible without a little trickery, like .withDefaultResult(null)
or .withDefaultResult(() -> null)
, with the latter only supported in the 0.12-SNAPSHOT. But maybe it could be a feature add? I'll tag it as an enhancement request and let's see if we can make that happen.
from rulebook.
Related Issues (20)
- rule book runner incorrectly eats exceptions so buggy code is not caught. HOT 2
- 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.