📄 abstractrule.java
字号:
package util;
/** TODO 3
* Created by IntelliJ IDEA.
* User: gexian
*在其execute()方法中,AbstractAction调用由子类实现的makeDecision()方法,
* 然后根据方法的返回值,调用组件定义的肯定或否定结果的方法。
*/
public abstract class AbstractRule extends AbstractComponent {
private AbstractComponent positiveOutcomeStep;
private AbstractComponent negativeOutcomeStep;
public void execute(Object arg) throws Exception {
boolean outcome = makeDecision(arg);
if(outcome)
positiveOutcomeStep.execute(arg);
else
negativeOutcomeStep.execute(arg);
}
protected abstract boolean makeDecision(Object arg) throws Exception;
public AbstractComponent getPositiveOutcomeStep() {
return positiveOutcomeStep;
}
public void setPositiveOutcomeStep(AbstractComponent positiveOutcomeStep) {
this.positiveOutcomeStep = positiveOutcomeStep;
}
public AbstractComponent getNegativeOutcomeStep() {
return negativeOutcomeStep;
}
public void setNegativeOutcomeStep(AbstractComponent negativeOutcomeStep) {
this.negativeOutcomeStep = negativeOutcomeStep;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -