Beanのコレクションがあり、それをempld、dept、projectでソートし、カスタムコンパレータを使用してソートし、apacheコレクションComparatorChainを使用してこのBeanのリストをソートするとします。Beanは次のとおりです。
public class Employee {
protected String empId; //alphanumeric e.g.abc123
protected String empFullName;
protected String empAddress;
protected String dept;
protected String project;
protected String customer;
public String getEmpId() {
return empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public String getEmpFullName() {
return empFullName;
}
public void setEmpFullName(String empFullName) {
this.empFullName = empFullName;
}
public String getEmpAddress() {
return empAddress;
}
public void setEmpAddress(String empAddress) {
this.empAddress = empAddress;
}
public String getDept() {
return dept;
}
public void setDept(String dept) {
this.dept = dept;
}
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
public String getCustomer() {
return customer;
}
public void setCustomer(String customer) {
this.customer = customer;
}
}
顧客の価値観は、たとえば、企業、政府、大学などです。
ここで、コレクションに数千のレコード(Bean)があり、顧客が会社の場合、同じempId(2回表示される可能性があります)に対して、顧客名がUniversityの同じempIdの下に移動する必要があるとします。顧客の記録が整理されていない可能性があるため、誰でも最初に表示される可能性があります。
したがって、基本的に、同じempIdを持つ2つ以上のレコードがあり、そのうちの1つにcustomer = Companyがある場合は、同じempIdを持つ注文の下に移動します。
効率的で可能なスレッドセーフな方法で、このレコードのスワッピング/再配置をどのように実現できますか。