/** * Selects all elements from inputCollection which don't match the given predicate * into an output collection. * <p> * If the input predicate is <code>null</code>, the result is an empty list. * * @param inputCollection the collection to get the input from, may not be null * @param predicate the predicate to use, may be null * @return the elements <b>not</b> matching the predicate (new list) * @throws NullPointerException if the input collection is null */ public static Collection selectRejected(Collection inputCollection, Predicate predicate) { ArrayList answer = new ArrayList(inputCollection.size()); selectRejected(inputCollection, predicate, answer); return answer; }
/** * Selects all elements from inputCollection which don't match the given predicate * into an output collection. * <p> * If the input predicate is <code>null</code>, the result is an empty list. * * @param inputCollection the collection to get the input from, may not be null * @param predicate the predicate to use, may be null * @return the elements <b>not</b> matching the predicate (new list) * @throws NullPointerException if the input collection is null */ public static Collection selectRejected(Collection inputCollection, Predicate predicate) { ArrayList answer = new ArrayList(inputCollection.size()); selectRejected(inputCollection, predicate, answer); return answer; }
public void testSelectRejected() { List list = new ArrayList(); list.add("One"); list.add("Two"); list.add("Three"); list.add("Four"); Collection output = CollectionUtils.selectRejected(list, EQUALS_TWO); assertEquals(4, list.size()); assertEquals(3, output.size()); assertTrue(output.contains("One")); assertTrue(output.contains("Three")); assertTrue(output.contains("Four")); }
/** * Returns a subcollection of the source collection containing all elements for which the expression evaluates * <code>false</code>. * @param collection * @param predicate * @return CollectionUtils.selectRejected(collection, predicate) */ public static Collection reject( final Collection collection, final Predicate predicate) { return CollectionUtils.selectRejected(collection, predicate); }
/** * The exact opposite to {@link #collectEventsWithExceptions()} Returns all the * {@link MuleEvent}s which messages have a <code>null</code> * {@link ExceptionPayload} or a <code>null</code> * {@link ExceptionPayload#getException()}. Notice that this is a collect * operation. Each time this method is invoked the result will be re-calculated * * @return a list of {@link MuleEvent}. It could be empty but it will never be * <code>null</code> */ @SuppressWarnings("unchecked") public List<MuleEvent> collectEventsWithoutExceptions() { return (List<MuleEvent>) CollectionUtils.selectRejected(this.events, failedEventsPredicate); }
/** * Selects all elements from inputCollection which don't match the given predicate * into an output collection. * <p> * If the input predicate is <code>null</code>, the result is an empty list. * * @param inputCollection the collection to get the input from, may not be null * @param predicate the predicate to use, may be null * @return the elements <b>not</b> matching the predicate (new list) * @throws NullPointerException if the input collection is null */ public static Collection selectRejected(Collection inputCollection, Predicate predicate) { ArrayList answer = new ArrayList(inputCollection.size()); selectRejected(inputCollection, predicate, answer); return answer; }
/** * Selects all elements from inputCollection which don't match the given predicate * into an output collection. * <p> * If the input predicate is <code>null</code>, the result is an empty list. * * @param inputCollection the collection to get the input from, may not be null * @param predicate the predicate to use, may be null * @return the elements <b>not</b> matching the predicate (new list) * @throws NullPointerException if the input collection is null */ public static Collection selectRejected(Collection inputCollection, Predicate predicate) { ArrayList answer = new ArrayList(inputCollection.size()); selectRejected(inputCollection, predicate, answer); return answer; }
/** * Selects all elements from inputCollection which don't match the given predicate * into an output collection. * <p> * If the input predicate is <code>null</code>, the result is an empty list. * * @param inputCollection the collection to get the input from, may not be null * @param predicate the predicate to use, may be null * @return the elements <b>not</b> matching the predicate (new list) * @throws NullPointerException if the input collection is null */ public static Collection selectRejected(Collection inputCollection, Predicate predicate) { ArrayList answer = new ArrayList(inputCollection.size()); selectRejected(inputCollection, predicate, answer); return answer; }
/** * Selects all elements from inputCollection which don't match the given predicate * into an output collection. * <p> * If the input predicate is <code>null</code>, the result is an empty list. * * @param inputCollection the collection to get the input from, may not be null * @param predicate the predicate to use, may be null * @return the elements <b>not</b> matching the predicate (new list) * @throws NullPointerException if the input collection is null */ public static Collection selectRejected(Collection inputCollection, Predicate predicate) { ArrayList answer = new ArrayList(inputCollection.size()); selectRejected(inputCollection, predicate, answer); return answer; }
/** * Selects all elements from inputCollection which don't match the given predicate * into an output collection. * <p> * If the input predicate is <code>null</code>, the result is an empty list. * * @param inputCollection the collection to get the input from, may not be null * @param predicate the predicate to use, may be null * @return the elements <b>not</b> matching the predicate (new list) * @throws NullPointerException if the input collection is null */ public static Collection selectRejected(Collection inputCollection, Predicate predicate) { ArrayList answer = new ArrayList(inputCollection.size()); selectRejected(inputCollection, predicate, answer); return answer; }
/** * Selects all elements from inputCollection which don't match the given * predicate * into an output collection. * <p> * If the input predicate is <code>null</code>, the result is an empty list. * * @param inputCollection * the collection to get the input from, may not be null * @param predicate * the predicate to use, may be null * @return the elements <b>not</b> matching the predicate (new list) * @throws NullPointerException * if the input collection is null */ public static <E> Collection<E> selectRejected(Collection<E> inputCollection, Predicate<E> predicate) { ArrayList<E> answer = new ArrayList<E>(inputCollection.size()); selectRejected(inputCollection, predicate, answer); return answer; }
@SuppressWarnings("unchecked") public static <E> List<E> selectRejected(ActionContext actionContext){ Thing self = actionContext.getObject("self"); Collection<? extends E> inputCollection = (Collection<? extends E>) self.doAction("getInputCollection", actionContext); Predicate predicate= (Predicate) self.doAction("getPredicate", actionContext); Collection<? extends E> cls = CollectionUtils.selectRejected(inputCollection, predicate); List<E> list = new ArrayList<E>(); for(E e : cls){ list.add(e); } return list; }
options = CollectionUtils.selectRejected(options, SPECIAL_OPTION_PREDICATE);