public TeacherLegalRegimen getLastLegalRegimenWithoutEndSituations() { YearMonthDay date = null; TeacherLegalRegimen regimenToReturn = null; for (TeacherLegalRegimen regimen : this.getLegalRegimens()) { if (!regimen.isEndSituation()) { if (regimen.isActive(new YearMonthDay())) { return regimen; } else if (date == null || date.isBefore(regimen.getEndDateYearMonthDay())) { date = regimen.getEndDateYearMonthDay(); regimenToReturn = regimen; } } } return regimenToReturn;
public TeacherLegalRegimen getLastLegalRegimenWithoutEndSituations(YearMonthDay begin, YearMonthDay end) { SortedSet<TeacherLegalRegimen> legalRegimens = new TreeSet<TeacherLegalRegimen>( TeacherLegalRegimen.TEACHER_LEGAL_REGIMEN_COMPARATOR_BY_BEGIN_DATE);  legalRegimens.addAll(getAllLegalRegimensWithoutEndSituations(begin, end)); return (!legalRegimens.isEmpty()) ? legalRegimens.last() : null;
    public TeacherLegalRegimen getLastLegalRegimenWithoutEndSituations() {        YearMonthDay date = null;        TeacherLegalRegimen regimenToReturn = null;        for (TeacherLegalRegimen regimen : this.getLegalRegimens()) {            if (!regimen.isEndSituation()) {                if (regimen.isActive(new YearMonthDay())) {                    return regimen;                } else if (date == null || date.isBefore(regimen.getEndDateYearMonthDay())) {                     date = regimen.getEndDateYearMonthDay();                     regimenToReturn = regimen;                }            }        }        return regimenToReturn;    }