/** * Returns a list of strongly referenced EventListeners. Removes * internal weak references to garbage collected listeners. * * @return */ @SuppressWarnings("unchecked") private synchronized <T extends EventListener> List<T> cleanReferences() { List<T> listeners = new ArrayList<T>(); for (int i = getReferences().size() - 1; i >= 0; i--) { Object listener = getReferences().get(i).get(); if (listener == null) { getReferences().remove(i); getClasses().remove(i); } else { listeners.add(0, (T) listener); } } return listeners; }
/** * Returns a list of strongly referenced EventListeners. Removes * internal weak references to garbage collected listeners. * * @return */ @SuppressWarnings("unchecked") private synchronized <T extends EventListener> List<T> cleanReferences() { List<T> listeners = new ArrayList<T>(); for (int i = getReferences().size() - 1; i >= 0; i--) { Object listener = getReferences().get(i).get(); if (listener == null) { getReferences().remove(i); getClasses().remove(i); } else { listeners.add(0, (T) listener); } } return listeners; }
/** * Returns a list of strongly referenced EventListeners. Removes * internal weak references to garbage collected listeners. * * @return */ @SuppressWarnings("unchecked") private synchronized <T extends EventListener> List<T> cleanReferences() { List<T> listeners = new ArrayList<T>(); for (int i = getReferences().size() - 1; i >= 0; i--) { Object listener = getReferences().get(i).get(); if (listener == null) { getReferences().remove(i); getClasses().remove(i); } else { listeners.add(0, (T) listener); } } return listeners; }
/** * Returns a list of strongly referenced EventListeners. Removes * internal weak references to garbage collected listeners. * * @return */ @SuppressWarnings("unchecked") private synchronized <T extends EventListener> List<T> cleanReferences() { List<T> listeners = new ArrayList<T>(); for (int i = getReferences().size() - 1; i >= 0; i--) { Object listener = getReferences().get(i).get(); if (listener == null) { getReferences().remove(i); getClasses().remove(i); } else { listeners.add(0, (T) listener); } } return listeners; }
/** * Returns a list of strongly referenced EventListeners. Removes * internal weak references to garbage collected listeners. * * @return */ @SuppressWarnings("unchecked") private synchronized <T extends EventListener> List<T> cleanReferences() { List<T> listeners = new ArrayList<T>(); for (int i = getReferences().size() - 1; i >= 0; i--) { Object listener = getReferences().get(i).get(); if (listener == null) { getReferences().remove(i); getClasses().remove(i); } else { listeners.add(0, (T) listener); } } return listeners; }
/** * Removes the listener as a listener of the specified type. * @param t the type of the listener to be removed * @param l the listener to be removed */ public synchronized <T extends EventListener> void remove(Class<T> t, T l) { if (l ==null) { // In an ideal world, we would do an assertion here // to help developers know they are probably doing // something wrong return; } if (!t.isInstance(l)) { throw new IllegalArgumentException("Listener " + l + " is not of type " + t); } for (int i = 0; i < getReferences().size(); i++) { if (l.equals(getReferences().get(i).get()) && (t == getClasses().get(i))) { getReferences().remove(i); getClasses().remove(i); break; } } }
/** * Removes the listener as a listener of the specified type. * @param t the type of the listener to be removed * @param l the listener to be removed */ public synchronized <T extends EventListener> void remove(Class<T> t, T l) { if (l ==null) { // In an ideal world, we would do an assertion here // to help developers know they are probably doing // something wrong return; } if (!t.isInstance(l)) { throw new IllegalArgumentException("Listener " + l + " is not of type " + t); } for (int i = 0; i < getReferences().size(); i++) { if (l.equals(getReferences().get(i).get()) && (t == getClasses().get(i))) { getReferences().remove(i); getClasses().remove(i); break; } } }
/** * Removes the listener as a listener of the specified type. * @param t the type of the listener to be removed * @param l the listener to be removed */ public synchronized <T extends EventListener> void remove(Class<T> t, T l) { if (l ==null) { // In an ideal world, we would do an assertion here // to help developers know they are probably doing // something wrong return; } if (!t.isInstance(l)) { throw new IllegalArgumentException("Listener " + l + " is not of type " + t); } for (int i = 0; i < getReferences().size(); i++) { if (l.equals(getReferences().get(i).get()) && (t == getClasses().get(i))) { getReferences().remove(i); getClasses().remove(i); break; } } }
/** * Removes the listener as a listener of the specified type. * @param t the type of the listener to be removed * @param l the listener to be removed */ public synchronized <T extends EventListener> void remove(Class<T> t, T l) { if (l ==null) { // In an ideal world, we would do an assertion here // to help developers know they are probably doing // something wrong return; } if (!t.isInstance(l)) { throw new IllegalArgumentException("Listener " + l + " is not of type " + t); } for (int i = 0; i < getReferences().size(); i++) { if (l.equals(getReferences().get(i).get()) && (t == getClasses().get(i))) { getReferences().remove(i); getClasses().remove(i); break; } } }
/** * Removes the listener as a listener of the specified type. * @param t the type of the listener to be removed * @param l the listener to be removed */ public synchronized <T extends EventListener> void remove(Class<T> t, T l) { if (l ==null) { // In an ideal world, we would do an assertion here // to help developers know they are probably doing // something wrong return; } if (!t.isInstance(l)) { throw new IllegalArgumentException("Listener " + l + " is not of type " + t); } for (int i = 0; i < getReferences().size(); i++) { if (l.equals(getReferences().get(i).get()) && (t == getClasses().get(i))) { getReferences().remove(i); getClasses().remove(i); break; } } }
/** * Adds the listener as a listener of the specified type. * As a side-effect, cleans out any garbage collected * listeners before adding. * @param t the type of the listener to be added * @param l the listener to be added */ public synchronized <T extends EventListener> void add(Class<T> t, T l) { if (l==null) { // In an ideal world, we would do an assertion here // to help developers know they are probably doing // something wrong return; } if (!t.isInstance(l)) { throw new IllegalArgumentException("Listener " + l + " is not of type " + t); } cleanReferences(); getReferences().add(new WeakReference<T>(l)); getClasses().add(t); }
/** * Adds the listener as a listener of the specified type. * As a side-effect, cleans out any garbage collected * listeners before adding. * @param t the type of the listener to be added * @param l the listener to be added */ public synchronized <T extends EventListener> void add(Class<T> t, T l) { if (l==null) { // In an ideal world, we would do an assertion here // to help developers know they are probably doing // something wrong return; } if (!t.isInstance(l)) { throw new IllegalArgumentException("Listener " + l + " is not of type " + t); } cleanReferences(); getReferences().add(new WeakReference<T>(l)); getClasses().add(t); }
/** * Adds the listener as a listener of the specified type. * As a side-effect, cleans out any garbage collected * listeners before adding. * @param t the type of the listener to be added * @param l the listener to be added */ public synchronized <T extends EventListener> void add(Class<T> t, T l) { if (l==null) { // In an ideal world, we would do an assertion here // to help developers know they are probably doing // something wrong return; } if (!t.isInstance(l)) { throw new IllegalArgumentException("Listener " + l + " is not of type " + t); } cleanReferences(); getReferences().add(new WeakReference<T>(l)); getClasses().add(t); }
/** * Adds the listener as a listener of the specified type. * As a side-effect, cleans out any garbage collected * listeners before adding. * @param t the type of the listener to be added * @param l the listener to be added */ public synchronized <T extends EventListener> void add(Class<T> t, T l) { if (l==null) { // In an ideal world, we would do an assertion here // to help developers know they are probably doing // something wrong return; } if (!t.isInstance(l)) { throw new IllegalArgumentException("Listener " + l + " is not of type " + t); } cleanReferences(); getReferences().add(new WeakReference<T>(l)); getClasses().add(t); }
/** * Adds the listener as a listener of the specified type. * As a side-effect, cleans out any garbage collected * listeners before adding. * @param t the type of the listener to be added * @param l the listener to be added */ public synchronized <T extends EventListener> void add(Class<T> t, T l) { if (l==null) { // In an ideal world, we would do an assertion here // to help developers know they are probably doing // something wrong return; } if (!t.isInstance(l)) { throw new IllegalArgumentException("Listener " + l + " is not of type " + t); } cleanReferences(); getReferences().add(new WeakReference<T>(l)); getClasses().add(t); }