A Light weight Java business rule engine.
- The current stable version is
1.1
: - The current snapshot version is
1.2-SNAPSHOT
: In order to use snapshot versions, you need to add the following maven repository in yourpom.xml
:
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
Maven dependency:
<dependencies>
<dependency>
<groupId>org.dvare</groupId>
<artifactId>dvare-rules</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
@Rule(name = "Dvare Rule")
public class DvareRule {
private static Logger logger = Logger.getLogger(DvareRule.class);
@Before
public void beforeCondition() {
logger.info("Before Condition ");
}
@Condition
public boolean condition(@Fact("rule") String rule, @Fact("person")Person person,
@RuleEngineType DvareRuleEngine textualRuleEngine) throws InterpretException {
return textualRuleEngine.register(rule, Person.class, person);
}
@After
public void afterCondition() {
logger.info("After Condition ");
}
@Success
public void success() {
logger.info("Rule Successfully Run");
}
@Fail
public void fail() {
logger.error("Rule Failed");
}
}
public class DvareRuleExample {
private static Logger logger = Logger.getLogger(DvareRule.class);
public static void main(String args[]) throws IllegalRuleException {
Person male = new Person();
male.setAge(25);
male.setGender("Male");
male.setTitle("Mr");
Facts facts = new Facts();
facts.add("rule", "age between [ 20 , 30 ] And title = 'Mr' And gender = 'Male'");
facts.add("person", male);
RuleEngine ruleEngine = new RuleEngineBuilder().facts(facts).build();
DvareRule dvareRule = new DvareRule();
ruleEngine.registerRule(dvareRule);
ruleEngine.fireRules();
boolean result = ruleEngine.getResult(dvareRule).getResult();
System.out.println(result);
}
}
Dvare rules is released under the .
The MIT License (MIT)
Copyright (c) 2016-2017 DVARE (Data Validation and Aggregation Rule Engine)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Sogiftware.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.