本文整理匯總了Java中org.apache.commons.collections.ListUtils.retainAll方法的典型用法代碼示例。如果您正苦於以下問題:Java ListUtils.retainAll方法的具體用法?Java ListUtils.retainAll怎麽用?Java ListUtils.retainAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.collections.ListUtils
的用法示例。
在下文中一共展示了ListUtils.retainAll方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setDimensionItemsForFilters
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
/**
* 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() ) );
Collections.sort( values, 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 );
}
示例2: setDimensionItemsForFilters
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
/**
* 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() ) );
Collections.sort( values, ObjectStringValueComparator.INSTANCE );
// Use order of items in filter if specified
List<?> itemList = filterItems != null ? ListUtils.retainAll( filterItems, values ) : values;
List<NameableObject> items = NameableObjectUtils.getNameableObjects( itemList, naForNull );
dim.setItems( items );
}