本文整理汇总了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 );
}