Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30024/src/net/sourceforge/bprocessor/model
Modified Files:
Entity.java
Log Message:
check to avoid null pointer exception in the comparator
Index: Entity.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Entity.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** Entity.java 11 Apr 2007 08:44:58 -0000 1.16
--- Entity.java 23 Apr 2007 14:48:38 -0000 1.17
***************
*** 68,77 ****
*/
public static void sort(List< ? > entities) {
! final Comparator<Object> comparator =
! new Comparator<Object>() {
! public int compare(Object s1, Object s2) {
! return ((Entity) s1).getId().compareTo(((Entity) s2).getId());
! }
! };
Collections.sort(entities, comparator);
}
--- 68,84 ----
*/
public static void sort(List< ? > entities) {
! final Comparator<Object> comparator = new Comparator<Object>() {
! public int compare(Object s1, Object s2) {
! Entity ent1 = (Entity) s1;
! Entity ent2 = (Entity) s2;
! Long id1 = ent1.getId();
! Long id2 = ent2.getId();
! int compare = 0;
! if (id1 == null || id2 == null) {
! return compare;
! }
! return id1.compareTo(id2);
! }
! };
Collections.sort(entities, comparator);
}
|