當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。