規則引擎-性別規則

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

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 = "Gender Rule", description = "Products Recommendation by Gender") public class GenderRule { private Properties actionResult = null; private int gender = 0; public GenderRule(Properties actionResult, int gender) { super(); this.actionResult = actionResult; this.gender = gender; } @Condition public boolean doCheck() { boolean OK = false; switch (this.gender) { case 0: // Any break; case 1: // Male OK = true; break; case 2: // Female break; } return (OK); } @Action public void doTask() throws Exception { synchronized (this.actionResult) { this.actionResult.put("GenderRule", "1"); } } @Priority public int getPriority() { return 1; } public int getGender() { return this.gender; } public void setGender(int gender) { this.gender = gender; } }