deliveredtechnologies / rulebook

100% Java, Lambda Enabled, Lightweight Rules Engine with a Simple and Intuitive DSL
http://www.deliveredtechnologies.com
Apache License 2.0
716 stars 124 forks source link

Rule name is dropping when build Rule withFactType. #197

Open mohdArshad9 opened 4 years ago

mohdArshad9 commented 4 years ago

If I am building a Rule .

RuleBuilder.create().withName("Rule1") .withResultType(Boolean.class) .withFactType("fact") .when(facts -> true) .then(facts -> { } ))

The rule name is dropping.In RuleBuilder.java line number 92 rule name is not copying from builder.

public <S> RuleBuilder<S, U> withFactType(Class<S> factType) { RuleBuilder<S, U> builder = new RuleBuilder<>(_ruleClass); builder._factType = factType; builder._resultType = _resultType; builder._actionType = _actionType; return builder; }

If we are building like this. It is working.

RuleBuilder.create() .withFactType("fact") .withName("Rule1") .withResultType(Boolean.class) .when(facts -> true) .then(facts -> { } ))

In RuleBuilder.java line number 106 rule name is copying from builder.So it is working.

public <S> RuleBuilder<T, S> withResultType(Class<S> resultType) { RuleBuilder<T, S> builder = new RuleBuilder<>(_ruleClass); builder._factType = _factType; builder._resultType = resultType; builder._actionType = _actionType; builder._name = _name; return builder; }

To avoid the maintaining order at rule building time.

Can I do a PR for it?

RuleBuilder.java line number 92.

public <S> RuleBuilder<S, U> withFactType(Class<S> factType) { RuleBuilder<S, U> builder = new RuleBuilder<>(_ruleClass); builder._factType = factType; builder._resultType = _resultType; builder._actionType = _actionType; builder._name = _name; return builder; }

Clayton7510 commented 3 years ago

Yes, pls.