if ((((degree.isBolonhaDegree() && degree.getBolonhaDegreeType().equals( BolonhaDegreeType.DEGREE)) || (!degree.isBolonhaDegree() && degree.getTipoCurso() .equals(DegreeType.DEGREE))) && unit.getType().equals(PartyTypeEnum.DEGREE)) || (((degree.isBolonhaDegree() && degree.getBolonhaDegreeType().equals( BolonhaDegreeType.MASTER_DEGREE)) || (!degree.isBolonhaDegree() && degree .getTipoCurso().equals(DegreeType.MASTER_DEGREE))) && unit.getType().equals( PartyTypeEnum.MASTER_DEGREE)) || ((degree.isBolonhaDegree() && degree.getBolonhaDegreeType().equals( BolonhaDegreeType.INTEGRATED_MASTER_DEGREE)) && unit.getType().equals( PartyTypeEnum.INTEGRATED_MASTER_DEGREE))) {  unit.setDegree(degree);  } else if (unit.getDegree() != null) { unit.removeDegree(); }  } else if (((degreeID != null && unit.getType() != null) || degreeID == null) && unit.getDegree() != null) {
} else if (unit.getDegree() != null) {
    private void setDegree(Integer degreeID, Unit unit) throws ExcepcaoPersistencia {        Degree degree = null;        if (degreeID != null                && unit.getType() != null                && (unit.getType().equals(PartyTypeEnum.DEGREE)                        || unit.getType().equals(PartyTypeEnum.MASTER_DEGREE) || unit.getType().equals(                        PartyTypeEnum.INTEGRATED_MASTER_DEGREE))) {            degree = rootDomainObject.readDegreeByOID(degreeID);            if ((((degree.isBolonhaDegree() && degree.getBolonhaDegreeType().equals(                    BolonhaDegreeType.DEGREE)) || (!degree.isBolonhaDegree() && degree.getTipoCurso()                    .equals(DegreeType.DEGREE))) && unit.getType().equals(PartyTypeEnum.DEGREE))                    || (((degree.isBolonhaDegree() && degree.getBolonhaDegreeType().equals(                            BolonhaDegreeType.MASTER_DEGREE)) || (!degree.isBolonhaDegree() && degree                            .getTipoCurso().equals(DegreeType.MASTER_DEGREE))) && unit.getType().equals(                            PartyTypeEnum.MASTER_DEGREE))                    || ((degree.isBolonhaDegree() && degree.getBolonhaDegreeType().equals(                            BolonhaDegreeType.INTEGRATED_MASTER_DEGREE)) && unit.getType().equals(                            PartyTypeEnum.INTEGRATED_MASTER_DEGREE))) {                unit.setDegree(degree);            } else if (unit.getDegree() != null) {                unit.removeDegree();            }        } else if (((degreeID != null && unit.getType() != null) || degreeID == null)                && unit.getDegree() != null) {            unit.removeDegree();        }    }