if (curricularRule.getCurricularRuleType() == CurricularRuleType.EXCLUSIVENESS) { final Exclusiveness exclusiveness = (Exclusiveness) curricularRule; if (exclusiveness.getExclusiveDegreeModule() == getDegreeModuleToApplyRule()) {  if (exclusiveness.belongsToCompositeRule()) { throw new DomainException("error.cannot.delete.rule.because.belongs.to.composite.rule", exclusiveness.getDegreeModuleToApplyRule().getName()); } curricularRulesIterator.remove(); exclusiveness.removeExclusiveDegreeModule(); exclusiveness.removeCommonParameters(); exclusiveness.deleteDomainObject(); }
if (curricularRule.getCurricularRuleType() == null) { final CompositeRule compositeRule = (CompositeRule) curricularRule; removeRuleFromCurrentExclusiveDegreeModule(compositeRule.getCurricularRulesIterator()); } else if (curricularRule.getCurricularRuleType() == this.getCurricularRuleType()) { removeExclusivenessRule(curricularRulesIterator, (Exclusiveness) curricularRule);
    private void removeRuleFromCurrentExclusiveDegreeModule() {        final Iterator<CurricularRule> curricularRulesIterator = this.getExclusiveDegreeModule().getCurricularRulesIterator();        while (curricularRulesIterator.hasNext()) {            final CurricularRule curricularRule = curricularRulesIterator.next();            if (curricularRule.getCurricularRuleType() == CurricularRuleType.EXCLUSIVENESS) {                final Exclusiveness exclusiveness = (Exclusiveness) curricularRule;                if (exclusiveness.getExclusiveDegreeModule() == getDegreeModuleToApplyRule()) {                                        if (exclusiveness.belongsToCompositeRule()) {                        throw new DomainException("error.cannot.delete.rule.because.belongs.to.composite.rule",                                exclusiveness.getDegreeModuleToApplyRule().getName());                    }                    curricularRulesIterator.remove();                    exclusiveness.removeExclusiveDegreeModule();                    exclusiveness.removeCommonParameters();                    exclusiveness.deleteDomainObject();                }            }        }    }