Last active
April 20, 2018 15:25
-
-
Save mill5james/367202b9d50d4353e4aae8778598c9f9 to your computer and use it in GitHub Desktop.
Rulebook problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.deliveredtechnologies.rulebook.Fact; | |
import com.deliveredtechnologies.rulebook.FactMap; | |
import com.deliveredtechnologies.rulebook.NameValueReferableMap; | |
import com.deliveredtechnologies.rulebook.model.runner.RuleBookRunner; | |
public class App { | |
public static void main(String[] args) { | |
RuleBookRunner rules = new RuleBookRunner("rules"); | |
NameValueReferableMap<String> facts = new FactMap<>(); | |
facts.put("key", new Fact<>("value")); | |
rules.run(facts); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package rules; | |
import com.deliveredtechnologies.rulebook.RuleState; | |
import com.deliveredtechnologies.rulebook.annotation.Given; | |
import com.deliveredtechnologies.rulebook.annotation.Rule; | |
import com.deliveredtechnologies.rulebook.annotation.Then; | |
import com.deliveredtechnologies.rulebook.annotation.When; | |
@Rule(order = 1) | |
public class ReturnsNext { | |
@Given("key") | |
String value; | |
@When | |
public boolean when() { return true; } | |
@Then | |
public RuleState then() { return RuleState.NEXT; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package rules; | |
import com.deliveredtechnologies.rulebook.RuleState; | |
import com.deliveredtechnologies.rulebook.annotation.Given; | |
import com.deliveredtechnologies.rulebook.annotation.Rule; | |
import com.deliveredtechnologies.rulebook.annotation.Then; | |
import com.deliveredtechnologies.rulebook.annotation.When; | |
@Rule(order = 2) | |
public class SimpleRule { | |
@Given("key") | |
String value; | |
@When | |
public boolean when() { return true; } | |
@Then | |
public RuleState then() { return RuleState.BREAK; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment