org.openwms.core.util.lang
Class CollectionUtil

java.lang.Object
  extended by org.openwms.core.util.lang.CollectionUtil

public final class CollectionUtil
extends Object

A CollectionUtil.

Since:
0.1
Version:
$Revision: 1409 $
Author:
Heiko Scherrer

Method Summary
static
<K,V> Map<K,V>
asHashMap(List<V> list, ListExtractor<K,V> extractor)
          Convert a list into a LinkedHashMap using a ListExtractor to determine the keys and values for the new Map.
static
<T> T
getFirstOrNull(List<T> list)
          Return the first element of list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFirstOrNull

public static <T> T getFirstOrNull(List<T> list)
Return the first element of list. If list is null of empty, null is returned.

Type Parameters:
T - Any type
Parameters:
list - The List
Returns:
list[0] or null if list == null || list.isEmpty

asHashMap

public static <K,V> Map<K,V> asHashMap(List<V> list,
                                       ListExtractor<K,V> extractor)
Convert a list into a LinkedHashMap using a ListExtractor to determine the keys and values for the new Map.

Type Parameters:
K - Type of list key
V - Type of list value
Parameters:
list - The list to convert
extractor - To determine key and value for each list entry
Returns:
A created LinkedHashMap or an empty map when one of the arguments is null


Copyright © 2005-2011 openwms.org. All Rights Reserved.