/** * Returns a collection containing all the elements in <code>collection</code> * that are also in <code>retain</code>. The cardinality of an element <code>e</code> * in the returned collection is the same as the cardinality of <code>e</code> * in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection <code>c</code> and thus cannot call <code>c.retainAll(retain);</code>. * * @param collection the collection whose contents are the target of the #retailAll operation * @param retain the collection containing the elements to be retained in the returned collection * @return a <code>Collection</code> containing all the elements of <code>collection</code> * that occur at least once in <code>retain</code>. * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ public static Collection retainAll(Collection collection, Collection retain) { return ListUtils.retainAll(collection, retain); }
/** * Returns a collection containing all the elements in <code>collection</code> * that are also in <code>retain</code>. The cardinality of an element <code>e</code> * in the returned collection is the same as the cardinality of <code>e</code> * in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection <code>c</code> and thus cannot call <code>c.retainAll(retain);</code>. * * @param collection the collection whose contents are the target of the #retailAll operation * @param retain the collection containing the elements to be retained in the returned collection * @return a <code>Collection</code> containing all the elements of <code>collection</code> * that occur at least once in <code>retain</code>. * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ public static Collection retainAll(Collection collection, Collection retain) { return ListUtils.retainAll(collection, retain); }
public void testRetainAll() { List sub = new ArrayList(); sub.add(a); sub.add(b); sub.add(x); List retained = ListUtils.retainAll(fullList, sub); assertTrue(retained.size() == 2); sub.remove(x); assertTrue(retained.equals(sub)); fullList.retainAll(sub); assertTrue(retained.equals(fullList)); try { List list = ListUtils.retainAll(null, null); fail("expecting NullPointerException"); } catch(NullPointerException npe){} // this is what we want }
/** * Returns a collection containing all the elements in <code>collection</code> * that are also in <code>retain</code>. The cardinality of an element <code>e</code> * in the returned collection is the same as the cardinality of <code>e</code> * in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection <code>c</code> and thus cannot call <code>c.retainAll(retain);</code>. * * @param collection the collection whose contents are the target of the #retailAll operation * @param retain the collection containing the elements to be retained in the returned collection * @return a <code>Collection</code> containing all the elements of <code>collection</code> * that occur at least once in <code>retain</code>. * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ public static Collection retainAll(Collection collection, Collection retain) { return ListUtils.retainAll(collection, retain); }
/** * Returns a collection containing all the elements in <code>collection</code> * that are also in <code>retain</code>. The cardinality of an element <code>e</code> * in the returned collection is the same as the cardinality of <code>e</code> * in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection <code>c</code> and thus cannot call <code>c.retainAll(retain);</code>. * * @param collection the collection whose contents are the target of the #retailAll operation * @param retain the collection containing the elements to be retained in the returned collection * @return a <code>Collection</code> containing all the elements of <code>collection</code> * that occur at least once in <code>retain</code>. * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ public static Collection retainAll(Collection collection, Collection retain) { return ListUtils.retainAll(collection, retain); }
/** * Returns a collection containing all the elements in <code>collection</code> * that are also in <code>retain</code>. The cardinality of an element <code>e</code> * in the returned collection is the same as the cardinality of <code>e</code> * in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection <code>c</code> and thus cannot call <code>c.retainAll(retain);</code>. * * @param collection the collection whose contents are the target of the #retailAll operation * @param retain the collection containing the elements to be retained in the returned collection * @return a <code>Collection</code> containing all the elements of <code>collection</code> * that occur at least once in <code>retain</code>. * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ public static Collection retainAll(Collection collection, Collection retain) { return ListUtils.retainAll(collection, retain); }
/** * Removes the elements in <code>remove</code> from <code>collection</code>. That is, this * method returns a collection containing all the elements in <code>c</code> * that are not in <code>remove</code>. The cardinality of an element <code>e</code> * in the returned collection is the same as the cardinality of <code>e</code> * in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection <code>c</code> and thus cannot call <code>collection.removeAll(remove);</code>. * * @param collection the collection from which items are removed (in the returned collection) * @param remove the items to be removed from the returned <code>collection</code> * @return a <code>Collection</code> containing all the elements of <code>collection</code> except * any elements that also occur in <code>remove</code>. * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ public static Collection removeAll(Collection collection, Collection remove) { return ListUtils.retainAll(collection, remove); }
/** * Returns a collection containing all the elements in <code>collection</code> * that are also in <code>retain</code>. The cardinality of an element <code>e</code> * in the returned collection is the same as the cardinality of <code>e</code> * in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection <code>c</code> and thus cannot call <code>c.retainAll(retain);</code>. * * @param collection the collection whose contents are the target of the #retailAll operation * @param retain the collection containing the elements to be retained in the returned collection * @return a <code>Collection</code> containing all the elements of <code>collection</code> * that occur at least once in <code>retain</code>. * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ public static Collection retainAll(Collection collection, Collection retain) { return ListUtils.retainAll(collection, retain); }
/** * Returns a collection containing all the elements in <code>collection</code> * that are also in <code>retain</code>. The cardinality of an element <code>e</code> * in the returned collection is the same as the cardinality of <code>e</code> * in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection <code>c</code> and thus cannot call <code>c.retainAll(retain);</code>. * * @param collection the collection whose contents are the target of the #retailAll operation * @param retain the collection containing the elements to be retained in the returned collection * @return a <code>Collection</code> containing all the elements of <code>collection</code> * that occur at least once in <code>retain</code>. * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ public static Collection retainAll(Collection collection, Collection retain) { return ListUtils.retainAll(collection, retain); }
/** * Returns a collection containing all the elements in <code>collection</code> * that are also in <code>retain</code>. The cardinality of an element <code>e</code> * in the returned collection is the same as the cardinality of <code>e</code> * in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection <code>c</code> and thus cannot call <code>c.retainAll(retain);</code>. * * @param collection the collection whose contents are the target of the #retailAll operation * @param retain the collection containing the elements to be retained in the returned collection * @return a <code>Collection</code> containing all the elements of <code>collection</code> * that occur at least once in <code>retain</code>. * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ public static Collection retainAll(Collection collection, Collection retain) { return ListUtils.retainAll(collection, retain); }
/** * Returns a collection containing all the elements in <code>collection</code> * that are also in <code>retain</code>. The cardinality of an element <code>e</code> * in the returned collection is the same as the cardinality of <code>e</code> * in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection <code>c</code> and thus cannot call <code>c.retainAll(retain);</code>. * * @param collection the collection whose contents are the target of the #retailAll operation * @param retain the collection containing the elements to be retained in the returned collection * @return a <code>Collection</code> containing all the elements of <code>collection</code> * that occur at least once in <code>retain</code>. * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ public static Collection retainAll(Collection collection, Collection retain) { return ListUtils.retainAll(collection, retain); }
/** * Removes the elements in <code>remove</code> from <code>collection</code>. That is, this * method returns a collection containing all the elements in <code>c</code> * that are not in <code>remove</code>. The cardinality of an element <code>e</code> * in the returned collection is the same as the cardinality of <code>e</code> * in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection <code>c</code> and thus cannot call <code>collection.removeAll(remove);</code>. * * @param collection the collection from which items are removed (in the returned collection) * @param remove the items to be removed from the returned <code>collection</code> * @return a <code>Collection</code> containing all the elements of <code>collection</code> except * any elements that also occur in <code>remove</code>. * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ public static Collection removeAll(Collection collection, Collection remove) { return ListUtils.retainAll(collection, remove); }
@SuppressWarnings("unchecked") public static <E> List<E> retainAll(ActionContext actionContext){ Thing self = actionContext.getObject("self"); Collection<E> collection = (Collection<E>) self.doAction("getCollection", actionContext); Collection<?> retain = (Collection<?>) self.doAction("getRetain", actionContext); return ListUtils.retainAll(collection, retain); }
@SuppressWarnings("unchecked") public static <E> List<E> removeAll(ActionContext actionContext){ Thing self = actionContext.getObject("self"); Collection<E> collection = (Collection<E>) self.doAction("getCollection", actionContext); Collection<?> remove = (Collection<?>) self.doAction("getRemove", actionContext); return ListUtils.retainAll(collection, remove); }
/** * Sets items on the given dimension based on the unique values of the matching * column in the given grid. Items are BaseNameableObjects where the name, * code and short name properties are set to the column value. The dimension * analytics type must be equal to EVENT. * * @param dimension the dimension. * @param naForNull indicates whether a [n/a] string should be used as * replacement for null values. * @param grid the grid with data values. */ public static void setDimensionItemsForFilters( DimensionalObject dimension, Grid grid, boolean naForNull ) { if ( dimension == null || grid == null || !AnalyticsType.EVENT.equals( dimension.getAnalyticsType() ) ) { return; } BaseDimensionalObject dim = (BaseDimensionalObject) dimension; List<String> filterItems = dim.getFilterItemsAsList(); List<Object> values = new ArrayList<>( grid.getUniqueValues( dim.getDimension() ) ); values.sort( ObjectStringValueComparator.INSTANCE ); // Use order of items in filter if specified List<?> itemList = filterItems != null ? ListUtils.retainAll( filterItems, values ) : values; List<DimensionalItemObject> items = getDimensionalItemObjects( itemList, naForNull ); dim.setItems( items ); }