規則引擎-年齡規則

主程式 年齡規則 性別規則 地區規則 例外城市規則 綜診規則

package com.emprogria; import java.util.Properties; import org.easyrules.annotation.Action; import org.easyrules.annotation.Condition; import org.easyrules.annotation.Priority; import org.easyrules.annotation.Rule; @Rule(name = "Age Rule", description = "Products Recommendation by Age") public class AgeRule { private Properties actionResult = null; private int age = 8; public AgeRule(Properties actionResult, int age) { super(); this.actionResult = actionResult; this.age = age; } @Condition public boolean doCheck() { boolean OK = (this.age > 6 && this.age < 15); return (OK); } @Action public void doTask() throws Exception { synchronized (this.actionResult) { this.actionResult.put("AgeRule", "1"); } } @Priority public int getPriority() { return 1; } public int getAge() { return this.age; } public void setAge(int age) { this.age = age; } }