void (ScrollbarStyleListener toAdd, ScrollbarStyleListener toRemove, List<? super ScrollbarStyleListener> list) { synchronized (ourStyleListeners) { Iterator<Reference<ScrollbarStyleListener>> iterator = ourStyleListeners.iterator(); while (iterator.hasNext()) { Reference<ScrollbarStyleListener> reference = iterator.next(); ScrollbarStyleListener ui = reference.get(); if (ui == null || ui == toRemove) { iterator.remove(); } else if (list != null) { list.add(ui); } } if (toAdd != null) { ourStyleListeners.add(new WeakReference<>(toAdd)); } } }