Ignore:
Timestamp:
2017-05-11T01:53:27+02:00 (18 months ago)
Author:
michael2402
Message:

Sonar: Make AbstractListenerInfo an interface.

File:
1 edited

Legend:

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

    r12109 r12116  
    4242    }
    4343
    44     private abstract static class AbstractListenerInfo {
    45         abstract void fire(SelectionChangeEvent event);
    46     }
    47 
    48     private static class ListenerInfo extends AbstractListenerInfo {
     44    private interface ListenerInfo {
     45        void fire(SelectionChangeEvent event);
     46    }
     47
     48    private static class OldListenerInfo implements ListenerInfo {
    4949        private final SelectionChangedListener listener;
    5050
    51         ListenerInfo(SelectionChangedListener listener) {
     51        OldListenerInfo(SelectionChangedListener listener) {
    5252            this.listener = listener;
    5353        }
    5454
    5555        @Override
    56         void fire(SelectionChangeEvent event) {
     56        public void fire(SelectionChangeEvent event) {
    5757            listener.selectionChanged(event.getSelection());
    5858        }
     
    6767            if (this == o) return true;
    6868            if (o == null || getClass() != o.getClass()) return false;
    69             ListenerInfo that = (ListenerInfo) o;
     69            OldListenerInfo that = (OldListenerInfo) o;
    7070            return Objects.equals(listener, that.listener);
    7171        }
    7272    }
    7373
    74     private static class DataListenerInfo extends AbstractListenerInfo {
     74    private static class DataListenerInfo implements ListenerInfo {
    7575        private final DataSelectionListener listener;
    7676
     
    8080
    8181        @Override
    82         void fire(SelectionChangeEvent event) {
     82        public void fire(SelectionChangeEvent event) {
    8383            listener.selectionChanged(event);
    8484        }
     
    9898    }
    9999
    100     private final CopyOnWriteArrayList<AbstractListenerInfo> inEDTListeners = new CopyOnWriteArrayList<>();
    101     private final CopyOnWriteArrayList<AbstractListenerInfo> immedatelyListeners = new CopyOnWriteArrayList<>();
     100    private final CopyOnWriteArrayList<ListenerInfo> inEDTListeners = new CopyOnWriteArrayList<>();
     101    private final CopyOnWriteArrayList<ListenerInfo> immedatelyListeners = new CopyOnWriteArrayList<>();
    102102
    103103    /**
     
    123123            throw new UnsupportedOperationException("IN_EDT mode not supported, you probably want to use IN_EDT_CONSOLIDATED.");
    124124        } else if (fireMode == FireMode.IN_EDT_CONSOLIDATED) {
    125             inEDTListeners.addIfAbsent(new ListenerInfo(listener));
     125            inEDTListeners.addIfAbsent(new OldListenerInfo(listener));
    126126        } else {
    127             immedatelyListeners.addIfAbsent(new ListenerInfo(listener));
     127            immedatelyListeners.addIfAbsent(new OldListenerInfo(listener));
    128128        }
    129129    }
     
    153153     */
    154154    public void removeSelectionListener(SelectionChangedListener listener) {
    155         remove(new ListenerInfo(listener));
     155        remove(new OldListenerInfo(listener));
    156156    }
    157157
     
    165165    }
    166166
    167     private void remove(AbstractListenerInfo searchListener) {
     167    private void remove(ListenerInfo searchListener) {
    168168        inEDTListeners.remove(searchListener);
    169169        immedatelyListeners.remove(searchListener);
     
    199199    }
    200200
    201     private static void fireEvent(List<AbstractListenerInfo> listeners, SelectionChangeEvent event) {
    202         for (AbstractListenerInfo listener: listeners) {
     201    private static void fireEvent(List<ListenerInfo> listeners, SelectionChangeEvent event) {
     202        for (ListenerInfo listener: listeners) {
    203203            listener.fire(event);
    204204        }
Note: See TracChangeset for help on using the changeset viewer.