使用特定条件从java basic程序中编写一些规则,如果条件满足,则运行相关规则

使用特定条件从java basic程序中编写一些规则,如果条件满足,则运行相关规则,java,heuristics,Java,Heuristics,我是java新手,我有一个类HashSetPropositions 类命题有4个类变量: public class Proposition extends HashSet<Proposition> implements RSTNode{ private String productName; private Property property; private Serializable value; private Type type;

我是java新手,我有一个类
HashSetPropositions

类命题有4个类变量:

public class Proposition extends HashSet<Proposition> implements RSTNode{
private String productName;
    private Property     property;
    private Serializable value;
    private Type         type;
    private Rating       rating;
}
我有如下类
RST规则

public class Propositions extends ArrayList<Proposition>{ 
........
}
public class RSTRule{
    protected String ruleName;
    protected String discourseRelation;
    protected RSTNode nucleus;
    protected RSTNode satellite;
    protected Condition condition;
    int heuristic;
    }
现在我有了另一个类,即
RSTRules,
,它包含一些方法,比如generate_1()、generate_2()、等等,。。。在这个方法中,我想在字段条件中写一些条件,如果这个条件为真,那么我应该运行相关的生成方法,但是如果条件不为真,我应该转到另一个生成方法并检查它的条件,依此类推, 我认为对于这个问题,我应该有一个单独的类,即“条件”来检查条件,但我不知道应该如何在条件类或构造函数中编写方法,这意味着我的条件类现在是空的

public class RSTRules extends ArrayList<RSTRule>  {
    RSTRule rstRule=new RSTRule();            
    Proposition prop1= new Proposition();
    Proposition prop2= new Proposition();   

    public RSTRule generate_1(){    
    my condition for generate_1() is like this:if(prop1.getName().equals.prop2.getName();
       rstRule.condition=.....
       rstRule.satellite=propSat;
       rstRule.nucleus=propNuc;
       rstRule.ruleName="BothSatisfy_ProductsSimilarities"
       rstRule.discourseRelation="Similarity"
       rstRule.heuristic=10;
       return rstRule;
    }



    public RSTRule generate_2(){
    my condition for generate_2() is like this: if(prop1.getValue().equals.prop2.getValue()

    rstRule.condition=.....
    rstRule.satellite=propSat;
    rstRule.nucleus=propNuc;
    rstRule.ruleName="BothFunction"
    rstRule.discourseRelation="Similarity"
    rstRule.heuristic=10;
    return rstRule;
    }
}
公共类RSTRules扩展了ArrayList{
RSTRule RSTRule=新的RSTRule();
命题prop1=新命题();
命题prop2=新命题();
公共RSTRule生成_1(){
生成_1()的条件如下:if(prop1.getName().equals.prop2.getName();
rstRule.condition=。。。。。
卫星=propSat;
核=原核;
rstRule.ruleName=“同时满足产品相似性”
rstRule.discusseRelation=“相似性”
rstRule.启发式=10;
返回rstRule;
}
公共RSTRule生成_2(){
生成_2()的条件如下:if(prop1.getValue().equals.prop2.getValue())
rstRule.condition=。。。。。
卫星=propSat;
核=原核;
rstRule.ruleName=“BothFunction”
rstRule.discusseRelation=“相似性”
rstRule.启发式=10;
返回rstRule;
}
}

我不确定我是否理解这一点……好的,我将尝试:在RSTRules类中,创建一个方法generate_any(),并在prop1.getValue()上使用开关大小写,在每种情况下,调用正确的generate方法。但我不能这样做,因为有时我应该检查值,有时我应该检查名称,另一些条件alsoSo
condition
应该有一个方法
boolean eval(Context ctx)
需要重写,并且上下文提供对所有内容的访问。