@Override public int compare(StudentModel o1, StudentModel o2) { if (o1.getGroupId() == o2.getGroupId()) { return o1.compareTo(o2); } else { return Integer.compare(o1.getGroupId(), o2.getGroupId()); } }
@Override public Object getValueAt(int rowIndex, int columnIndex) { StudentModel student = students.get(rowIndex); int val; switch (Columns.values()[columnIndex]) { case SURNAME: return student.getSurname(); case GROUP: val = student.getGroupId(); return val >= 0 ? val : ""; case MATAN: val = student.getMarks().get(0); return val >= 0 ? val : ""; case GA: val = student.getMarks().get(1); return val >= 0 ? val : ""; case PROGRAMMING: val = student.getMarks().get(2); return val >= 0 ? val : ""; case AVERAGE: double average = student.getAverage(); return average >= 0 ? average : ""; default: return null; } }