Changeset 16218 in josm for trunk


Ignore:
Timestamp:
2020-03-29T10:20:52+02:00 (4 years ago)
Author:
GerdP
Message:

simplify sort

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java

    r16216 r16218  
    9696    protected void sort() {
    9797        data.sort((c1, c2) -> {
    98                 if (c1.getModificationType() == c2.getModificationType()) {
    99                     long id1 = c1.getPrimitive().getId();
    100                     long id2 = c2.getPrimitive().getId();
    101 
    102                     if (id1 == id2)
    103                         return 0;
    104                     else if (id1 < id2)
    105                         return -1;
    106                     return 1;
    107                 }
    108                 switch(c1.getModificationType()) {
    109                 case CREATED: return -1;
    110                 case UPDATED:
    111                     switch(c2.getModificationType()) {
    112                     case CREATED: return 1;
    113                     default: return -1;
    114                     }
    115                 case DELETED:
    116                     return 1;
    117                 }
    118                 // should not happen
    119                 return 0;
     98            int d = c1.getModificationType().compareTo(c2.getModificationType());
     99            if (d == 0) {
     100                d = Long.compare(c1.getPrimitive().getId(), c2.getPrimitive().getId());
     101            }
     102            return d;
    120103            }
    121104        );
Note: See TracChangeset for help on using the changeset viewer.