public void unregister(final Class<?> eventType, final Object target) { if (listeners != null) { Iterators.removeIf( listeners.iterator(), new Predicate<ListenerMethod>() { @Override public boolean apply(ListenerMethod m) { return m.matches(eventType, target); } }); } }
public void unregister(Predicate<ListenerMethod> predicate) { if (listeners != null) { Iterators.removeIf(listeners.iterator(), predicate); } }
/** * Removes, from an iterable, every element that satisfies the provided predicate. * * @param removeFrom the iterable to (potentially) remove elements from * @param predicate a predicate that determines whether an element should be removed * @return {@code true} if any elements were removed from the iterable * @throws UnsupportedOperationException if the iterable does not support {@code remove()}. * @since 2.0 */ public static <T> boolean removeIf(Iterable<T> removeFrom, Predicate<? super T> predicate) { if (removeFrom instanceof RandomAccess && removeFrom instanceof List) { return removeIfFromRandomAccessList((List<T>) removeFrom, checkNotNull(predicate)); } return Iterators.removeIf(removeFrom.iterator(), predicate); }