対応するコンパレーターが定義されているStudentUnionクラスがあり、それがクラスのメンバーオブジェクトになったときにStudent、同じファクターでコレクション内でソートされたい (学生ユニオンでソートされた) 場合、別のコンパレーターの再コーディングを回避する方法とほとんど同じ仕事をしStudentUnionComparatorますか?そのような状況の最適な設計はありますか?
public class Student{
....
private StudentUnion;
....
}
public class StudentUnionComparator implements Comparator<StudentUnion>{
public int compare(StudentUnion s1, StudentUnion s2){
....
return result // 1 or 0;
}
}