Demo entry 6686736

11

   

Submitted by anonymous on Dec 25, 2017 at 03:40
Language: Java. Code size: 2.3 kB.

public class RuleBean implements Comparable<RuleBean>
{
    private BasicRuleBean basicRuleBean;
    private BasicRuleBean parentRule;
    private BasicRuleBean subRule;

    public RuleBean()
    {
        basicRuleBean = new BasicRuleBean();
        parentRule = new BasicRuleBean();
        subRule = new BasicRuleBean();
    }

    @VisibleForTesting
    public RuleBean(BasicRuleBean basicRuleBean)
    {
        this.basicRuleBean = basicRuleBean;
    }

    public BasicRuleBean getBasicRuleBean()
    {
        return basicRuleBean;
    }

    public void setBasicRuleBean(BasicRuleBean basicRuleBean)
    {
        this.basicRuleBean = basicRuleBean;
    }

    public BasicRuleBean getParentRule()
    {
        return parentRule;
    }

    public void setParentRule(BasicRuleBean parentRule)
    {
        this.parentRule = parentRule;
    }

    public BasicRuleBean getSubRule()
    {
        return subRule;
    }

    public void setSubRule(BasicRuleBean subRule)
    {
        this.subRule = subRule;
    }

    @Override
    public boolean equals(Object o)
    {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;
        RuleBean that = (RuleBean) o;
        return basicRuleBean.equals(that.getBasicRuleBean()) && parentRule
            .equals(that.getParentRule()) && subRule.equals(that.getSubRule());
    }

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((basicRuleBean == null) ? 0 : basicRuleBean.hashCode());
        result = prime * result + ((parentRule == null) ? 0 : parentRule.hashCode());
        result = prime * result + ((subRule == null) ? 0 : subRule.hashCode());
        return result;
    }

    @Override
    public int compareTo(RuleBean o)
    {

        if (!basicRuleBean.equals(o.getBasicRuleBean()))
        {
            return basicRuleBean.compareTo(o.getBasicRuleBean());
        }
        if (!parentRule.equals(o.getParentRule()))
        {
            return parentRule.compareTo(o.getParentRule());
        }
        return subRule.compareTo(o.getSubRule());
    }
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).