Changeset 10608 in josm for trunk/src/org/openstreetmap/josm/data/osm/NoteData.java
- Timestamp:
- 2016-07-23T15:46:39+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/NoteData.java
r10134 r10608 16 16 import org.openstreetmap.josm.data.notes.NoteComment; 17 17 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 18 import org.openstreetmap.josm.tools.Predicate;19 18 import org.openstreetmap.josm.tools.Utils; 20 19 … … 37 36 * Within each subgroup it sorts by ID 38 37 */ 39 public static final Comparator<Note> DEFAULT_COMPARATOR = new Comparator<Note>() { 40 @Override 41 public int compare(Note n1, Note n2) { 42 if (n1.getId() < 0 && n2.getId() > 0) { 43 return 1; 44 } 45 if (n1.getId() > 0 && n2.getId() < 0) { 46 return -1; 47 } 48 if (n1.getState() == State.CLOSED && n2.getState() == State.OPEN) { 49 return 1; 50 } 51 if (n1.getState() == State.OPEN && n2.getState() == State.CLOSED) { 52 return -1; 53 } 54 return Long.compare(Math.abs(n1.getId()), Math.abs(n2.getId())); 55 } 38 public static final Comparator<Note> DEFAULT_COMPARATOR = (n1, n2) -> { 39 if (n1.getId() < 0 && n2.getId() > 0) { 40 return 1; 41 } 42 if (n1.getId() > 0 && n2.getId() < 0) { 43 return -1; 44 } 45 if (n1.getState() == State.CLOSED && n2.getState() == State.OPEN) { 46 return 1; 47 } 48 if (n1.getState() == State.OPEN && n2.getState() == State.CLOSED) { 49 return -1; 50 } 51 return Long.compare(Math.abs(n1.getId()), Math.abs(n2.getId())); 56 52 }; 57 53 58 54 /** Sorts notes strictly by creation date */ 59 public static final Comparator<Note> DATE_COMPARATOR = new Comparator<Note>() { 60 @Override 61 public int compare(Note n1, Note n2) { 55 public static final Comparator<Note> DATE_COMPARATOR = (n1, n2) -> n1.getCreatedAt().compareTo(n2.getCreatedAt()); 56 57 /** Sorts notes by user, then creation date */ 58 public static final Comparator<Note> USER_COMPARATOR = (n1, n2) -> { 59 String n1User = n1.getFirstComment().getUser().getName(); 60 String n2User = n2.getFirstComment().getUser().getName(); 61 if (n1User.equals(n2User)) { 62 62 return n1.getCreatedAt().compareTo(n2.getCreatedAt()); 63 63 } 64 return n1.getFirstComment().getUser().getName().compareTo(n2.getFirstComment().getUser().getName()); 64 65 }; 65 66 66 /** Sorts notes by user, then creation date */67 public static final Comparator<Note> USER_COMPARATOR = new Comparator<Note>() {68 @Override69 public int compare(Note n1, Note n2) {70 String n1User = n1.getFirstComment().getUser().getName();71 String n2User = n2.getFirstComment().getUser().getName();72 if (n1User.equals(n2User)) {73 return n1.getCreatedAt().compareTo(n2.getCreatedAt());74 }75 return n1.getFirstComment().getUser().getName().compareTo(n2.getFirstComment().getUser().getName());76 }77 };78 79 67 /** Sorts notes by the last modified date */ 80 public static final Comparator<Note> LAST_ACTION_COMPARATOR = new Comparator<Note>() { 81 @Override 82 public int compare(Note n1, Note n2) { 83 Date n1Date = n1.getComments().get(n1.getComments().size()-1).getCommentTimestamp(); 84 Date n2Date = n2.getComments().get(n2.getComments().size()-1).getCommentTimestamp(); 85 return n1Date.compareTo(n2Date); 86 } 68 public static final Comparator<Note> LAST_ACTION_COMPARATOR = (n1, n2) -> { 69 Date n1Date = n1.getComments().get(n1.getComments().size()-1).getCommentTimestamp(); 70 Date n2Date = n2.getComments().get(n2.getComments().size()-1).getCommentTimestamp(); 71 return n1Date.compareTo(n2Date); 87 72 }; 88 73 … … 169 154 } else { 170 155 final Note existingNote = noteList.get(newNote); 171 final boolean isDirty = Utils.exists(existingNote.getComments(), new Predicate<NoteComment>() { 172 @Override 173 public boolean evaluate(NoteComment object) { 174 return object.isNew(); 175 } 176 }); 156 final boolean isDirty = Utils.exists(existingNote.getComments(), object -> object.isNew()); 177 157 if (!isDirty) { 178 158 noteList.put(newNote);
Note:
See TracChangeset
for help on using the changeset viewer.