当前位置: 首页>>代码示例>>Java>>正文


Java ListUtils.retainAll方法代码示例

本文整理汇总了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 );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:35,代码来源:DimensionalObjectUtils.java

示例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 );
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:35,代码来源:DimensionalObjectUtils.java


注:本文中的org.apache.commons.collections.ListUtils.retainAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。