IndirectCriterionRequirement getCurrentIndirectRequirement(
Set<IndirectCriterionRequirement> oldIndirects,
CriterionRequirement requirement) {
IndirectCriterionRequirement indirect;
DirectCriterionRequirement parent;
boolean valid = true;
if (requirement instanceof DirectCriterionRequirement) {
parent = (DirectCriterionRequirement) requirement;
} else {
parent = ((IndirectCriterionRequirement) requirement).getParent();
valid = ((IndirectCriterionRequirement) requirement).isValid();
}
indirect = findIndirectRequirementByParent(oldIndirects, parent);
if (indirect == null) {
indirect = IndirectCriterionRequirement.create(parent, requirement
.getCriterion());
indirect.setValid(valid);
}
return (IndirectCriterionRequirement) indirect;
}