I’ve got a very weird issue. I’ve got this Procedure object that contains two rules. Now I wanted to loop out those rules with a for loop and get 1 rule back. But I always get null. It looks like he is skipping the if statement and directly goes to my return null part.
The name of the first rule is age, and the name of the other rule is accidents. I’ve included the method here.
My log is giving back:
rulename: ‘age’ and variable: ‘accidents’ and is true ?: ‘false’
rulename: ‘accidents’ and variable: ‘accidents’ and is true ?: ‘true’
private Rule searchRule(String ruleName)
{
List<Rule> test = this.procedureObject.getRules();
for(Rule rule : test)
{
Log.d("debug", "rulename: '" + rule.getName() + "' and variable: '"+ruleName+"' and is true ?: '"+rule.getName().equalsIgnoreCase(ruleName)+"'");
if(rule.getName().equalsIgnoreCase(ruleName))
{
return rule;
}
}
return null;
}
EDIT: it works now.
I just changed this in the calling code:
Rule makeRule = RuleFactory.getNewRuleClassNameInstance(this.searchRule(ref2.getName()).getClass().getSimpleName());
to:
Rule foundRule = this.searchRule(ref2.getName());
Rule makeRule = RuleFactory.getNewRuleClassNameInstance(foundRule.getClass().getSimpleName());
And then it suddenly works.
I changed:
to:
and then it seemed to work.