0
일반 속성을 가진 개체 목록과 사용자 지정 필드 값의 해시 맵이 있는데 해당 맵의 사용자 지정 필드 값을 기준으로 정렬 방법을 찾으려고합니다.BeanComparator를 사용하여 매핑 된 속성으로 정렬
예 클래스 :
class Result {
int id;
String name;
Date date;
Map customFields;
int getId() {
return id;
}
etc....
String getCustomField(String fieldId) {
return customFields.get(fieldId);
}
public void setCustomField(String fieldId, Object value) {
customFields.put(fieldId, value);
}
}
목록이 잘 정렬 "정상"특성을 가진 BeanComparator 사용.
java.lang.RuntimeException가 :의 경우는, NoSuchMethodException : java.lang.NoSuchMethodException을 :하지만 매핑 속성을 시도하는 것은 나에게주는 알 수없는 재산 빈 클래스 결과에 'customField'+를 여기
가 어떻게 내가 할 노력하고있어 :
ComparatorChain chain = new ComparatorChain();
chain.addComparator(new BeanComparator("customField(field99)"));
Collections.sort(results, chain);
아이디어가 있으십니까?
TIA