Ignore:
Timestamp:
2017-08-06T20:24:40+02:00 (4 years ago)
Author:
michael2402
Message:

See #15057: Fix checkstye and sonar issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/download/OverpassQueryList.java

    r12574 r12575  
    5656public final class OverpassQueryList extends SearchTextResultListPanel<OverpassQueryList.SelectorItem> {
    5757
    58     private final DateTimeFormatter format = DateTimeFormatter.ofPattern("HH:mm:ss, dd-MM-yyyy");
     58    private static final DateTimeFormatter FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss, dd-MM-yyyy");
    5959
    6060    /*
     
    8585        this.target = target;
    8686        this.componentParent = parent;
    87         this.items = this.restorePreferences();
     87        this.items = restorePreferences();
    8888
    8989        OverpassQueryListMouseAdapter mouseHandler = new OverpassQueryListMouseAdapter(lsResult, lsResultModel);
     
    134134        if (!historicExist) {
    135135            SelectorItem item = new SelectorItem(
    136                     "history " + LocalDateTime.now().format(this.format),
     136                    "history " + LocalDateTime.now().format(FORMAT),
    137137                    query);
    138138
     
    261261     * @return A set of the user saved items.
    262262     */
    263     private Map<String, SelectorItem> restorePreferences() {
     263    private static Map<String, SelectorItem> restorePreferences() {
    264264        Collection<Map<String, String>> toRetrieve =
    265265                Main.pref.getListOfStructs(PREFERENCE_ITEMS, Collections.emptyList());
     
    279279    private class OverpassQueryListMouseAdapter extends MouseAdapter {
    280280
    281         private final JList list;
    282         private final ResultListModel model;
     281        private final JList<SelectorItem> list;
     282        private final ResultListModel<SelectorItem> model;
    283283        private final JPopupMenu emptySelectionPopup = new JPopupMenu();
    284284        private final JPopupMenu elementPopup = new JPopupMenu();
    285         private final JPopupMenu queryLookup = new JPopupMenu();
    286 
    287         OverpassQueryListMouseAdapter(JList list, ResultListModel listModel) {
     285
     286        OverpassQueryListMouseAdapter(JList<SelectorItem> list, ResultListModel<SelectorItem> listModel) {
    288287            this.list = list;
    289288            this.model = listModel;
     
    331330            }
    332331
    333             SelectorItem item = (SelectorItem) model.getElementAt(idx);
     332            SelectorItem item = model.getElementAt(idx);
    334333            list.setToolTipText("<html><pre style='width:300px;'>" +
    335334                    Utils.escapeReservedCharactersHTML(Utils.restrictStringLines(item.getQuery(), 9)));
     
    607606
    608607        @Override
    609         public boolean equals(Object o) {
    610             if (this == o) return true;
    611             if (!(o instanceof SelectorItem)) return false;
    612 
    613             SelectorItem that = (SelectorItem) o;
    614 
    615             return itemKey.equals(that.itemKey) &&
    616                     query.equals(that.getKey());
     608        public int hashCode() {
     609            final int prime = 31;
     610            int result = 1;
     611            result = prime * result + ((itemKey == null) ? 0 : itemKey.hashCode());
     612            result = prime * result + ((query == null) ? 0 : query.hashCode());
     613            return result;
    617614        }
    618615
    619616        @Override
    620         public int hashCode() {
    621             return itemKey.hashCode();
     617        public boolean equals(Object obj) {
     618            if (this == obj) {
     619                return true;
     620            }
     621            if (obj == null) {
     622                return false;
     623            }
     624            if (getClass() != obj.getClass()) {
     625                return false;
     626            }
     627            SelectorItem other = (SelectorItem) obj;
     628            if (itemKey == null) {
     629                if (other.itemKey != null) {
     630                    return false;
     631                }
     632            } else if (!itemKey.equals(other.itemKey)) {
     633                return false;
     634            }
     635            if (query == null) {
     636                if (other.query != null) {
     637                    return false;
     638                }
     639            } else if (!query.equals(other.query)) {
     640                return false;
     641            }
     642            return true;
    622643        }
    623644    }
Note: See TracChangeset for help on using the changeset viewer.