package net.sourceforge.fenixedu.domain; import java.util.Comparator; import java.util.List; /** * @author dcs-rjao * * 21/Mar/2003 */ public class CurricularYear extends CurricularYear_Base implements Comparable { public static Comparator CURRICULAR_YEAR_COMPARATORY_BY_YEAR = new Comparator() { @Override public int compare(CurricularYear o1, CurricularYear o2) { return o1.getYear().compareTo(o2.getYear()); } }; public CurricularYear() { super(); setRootDomainObject(RootDomainObject.getInstance()); } public CurricularYear(final Integer year, final int numberOfSemesters) { this(); setYear(year); for (int i = 1; i <= numberOfSemesters; i++) { new CurricularSemester(this, Integer.valueOf(i)); } } public int compareTo(final CurricularYear curricularYear) { return getYear().compareTo(curricularYear.getYear()); } public CurricularSemester getCurricularSemester(final Integer semester) { for (final CurricularSemester curricularSemester : getCurricularSemestersSet()) { if (curricularSemester.getSemester().equals(semester)) { return curricularSemester; } } return null; } public static CurricularYear readByYear(Integer year) { List curricularYears = RootDomainObject.getInstance().getCurricularYears(); for (CurricularYear curricularYear : curricularYears) { if (curricularYear.getYear().equals(year)) { return curricularYear; } } return null; } }