Class XCollectionUtils


  • public class XCollectionUtils
    extends Object
    Utility class for operations on collections
    Since:
    7.0.0
    Author:
    XIMA Media GmbH
    • 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 null if 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 null if the list is null or empty, or the last item is null.
      • serializableList

        public static <T> List<T> serializableList​(Iterable<T> sequence)
        Takes any Collection or Iterable and 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.