Ignore:
Timestamp:
2017-04-01T23:27:46+02:00 (3 years ago)
Author:
Don-vip
Message:

findbugs - EI_EXPOSE_REP2 - Note dates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/NoteData.java

    r10717 r11821  
    2626    private final Storage<Note> noteList;
    2727    private Note selectedNote;
    28     private Comparator<Note> comparator = DEFAULT_COMPARATOR;
    29 
    30     /**
    31      * Sorts notes in the following order:
    32      * 1) Open notes
    33      * 2) Closed notes
    34      * 3) New notes
    35      * Within each subgroup it sorts by ID
    36      */
    37     public static final Comparator<Note> DEFAULT_COMPARATOR = (n1, n2) -> {
    38         if (n1.getId() < 0 && n2.getId() > 0) {
    39             return 1;
    40         }
    41         if (n1.getId() > 0 && n2.getId() < 0) {
    42             return -1;
    43         }
    44         if (n1.getState() == State.CLOSED && n2.getState() == State.OPEN) {
    45             return 1;
    46         }
    47         if (n1.getState() == State.OPEN && n2.getState() == State.CLOSED) {
    48             return -1;
    49         }
    50         return Long.compare(Math.abs(n1.getId()), Math.abs(n2.getId()));
    51     };
    52 
    53     /** Sorts notes strictly by creation date */
    54     public static final Comparator<Note> DATE_COMPARATOR = (n1, n2) -> n1.getCreatedAt().compareTo(n2.getCreatedAt());
    55 
    56     /** Sorts notes by user, then creation date */
    57     public static final Comparator<Note> USER_COMPARATOR = (n1, n2) -> {
    58         String n1User = n1.getFirstComment().getUser().getName();
    59         String n2User = n2.getFirstComment().getUser().getName();
    60         if (n1User.equals(n2User)) {
    61             return n1.getCreatedAt().compareTo(n2.getCreatedAt());
    62         }
    63         return n1.getFirstComment().getUser().getName().compareTo(n2.getFirstComment().getUser().getName());
    64     };
    65 
    66     /** Sorts notes by the last modified date */
    67     public static final Comparator<Note> LAST_ACTION_COMPARATOR = (n1, n2) -> {
    68         Date n1Date = n1.getComments().get(n1.getComments().size()-1).getCommentTimestamp();
    69         Date n2Date = n2.getComments().get(n2.getComments().size()-1).getCommentTimestamp();
    70         return n1Date.compareTo(n2Date);
    71     };
     28    private Comparator<Note> comparator = Note.DEFAULT_COMPARATOR;
    7229
    7330    /**
Note: See TracChangeset for help on using the changeset viewer.