if (teacher != null && teacher.getTeacherNumber().equals(teacherNumber)) {
if (teacher != null && teacher.getTeacherNumber().equals(teacherNumber) && !teacher.getAllLegalRegimensBelongsToPeriod(begin, end).isEmpty()) {
    public Teacher getTeacherByPeriod(Integer teacherNumber, Date begin, Date end) {        for (Employee employee : getWorkingEmployees(begin, end)) {            Teacher teacher = employee.getPerson().getTeacher();            if (teacher != null && teacher.getTeacherNumber().equals(teacherNumber)) {                return teacher;            }        }        return null;    }