Package de.xima.fc.utils
Class XCollectionUtils
- java.lang.Object
 - 
- de.xima.fc.utils.XCollectionUtils
 
 
- 
public class XCollectionUtils extends Object
Utility class for operations on collections- Since:
 - 7.0.0
 - Author:
 - XIMA Media GmbH
 
 
- 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TfirstItem(List<T> list)static <T> TlastItem(List<T> list)static <T> List<T>listOfSize(int targetSize, T initialValue)static <T> List<T>listOfSizeWith(int targetSize, IntFunction<T> initialValue)static <T> List<T>serializableList(Iterable<T> sequence)Takes anyCollectionorIterableand converts it to a serializable list that can be transferred via the API. 
 - 
 
- 
- 
Method Detail
- 
firstItem
public static <T> T firstItem(List<T> list)
- Type Parameters:
 T- Type of the elements in the list.- Parameters:
 list- List to process.- Returns:
 - The first item in the list, or 
nullif the list is null or empty, or the first item is null. 
 
- 
lastItem
public static <T> T lastItem(List<T> list)
- Type Parameters:
 T- Type of the elements in the list.- Parameters:
 list- List to process.- Returns:
 - The last item in the list, or 
nullif the list is null or empty, or the last item is null. 
 
- 
serializableList
public static <T> List<T> serializableList(Iterable<T> sequence)
Takes anyCollectionorIterableand converts it to a serializable list that can be transferred via the API.- Type Parameters:
 T- Type of the list items.- Parameters:
 sequence- A sequence of items to put into a list.- Returns:
 - A serializable list with the given items.
 
 
- 
listOfSize
public static <T> List<T> listOfSize(int targetSize, T initialValue)
- Type Parameters:
 T- Type of the list elements.- Parameters:
 targetSize- Desired size of the list.initialValue- Initial value for each element.- Returns:
 - A list of the given size, with each element set to the given initial value.
 
 
- 
listOfSizeWith
public static <T> List<T> listOfSizeWith(int targetSize, IntFunction<T> initialValue)
- Type Parameters:
 T- Type of the list elements.- Parameters:
 targetSize- Desired size of the list.initialValue- Supplier for the initial value for each element.- Returns:
 - A list of the given size, with each element set to the value returned by the given supplier.
 
 
 - 
 
 -