規則引擎-綜診規則 (第三階規則)

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

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 = "Final Rule", description = "Products Recommendation") public class FinalRule { private Properties actionResult = null; public FinalRule(Properties actionResult) { super(); this.actionResult = actionResult; } @Condition public boolean doCheck() { boolean OK = (this.actionResult.getProperty("AgeRule") == "1" && this.actionResult.getProperty("GenderRule") == "1" && this.actionResult.getProperty("RegionRule") == "1") || (this.actionResult.getProperty("CityRule") == "2"); return (OK); } @Action public void doTask() throws Exception { synchronized (this.actionResult) { this.actionResult.put("FinalRule", "3"); } } @Priority public int getPriority() { return 3; } }