Class ManifoldListCollectionExt


  • public class ManifoldListCollectionExt
    extends Object
    • Constructor Detail

      • ManifoldListCollectionExt

        public ManifoldListCollectionExt()
    • Method Detail

      • first

        public static <E> E first​(List<E> thiz)
        Returns first element.
        Throws:
        NoSuchElementException - if the list is empty.
      • firstOrNull

        public static <E> E firstOrNull​(List<E> thiz)
        Returns the first element, or null if the list is empty.
      • last

        public static <E> E last​(List<E> thiz)
        Returns the last element.
        Throws:
        NoSuchElementException - if the list is empty.
      • last

        public static <E> E last​(List<E> thiz,
                                 Predicate<E> predicate)
        Returns the last element matching the given predicate.
        Throws:
        NoSuchElementException - if no such element is found.
      • lastOrNull

        public static <E> E lastOrNull​(List<E> thiz)
        Returns the last element, or null if the list is empty.
      • lastOrNull

        public static <E> E lastOrNull​(List<E> thiz,
                                       Predicate<E> predicate)
        Returns the last element matching the given predicate, or null if no such element was found.
      • single

        public static <E> E single​(List<E> thiz)
        Returns the single element, or throws an exception if the list is empty or has more than one element.
      • singleOrNull

        public static <E> E singleOrNull​(List<E> thiz)
        Returns single element, or null if the list is empty or has more than one element.
      • getOrNull

        public static <E> E getOrNull​(List<E> thiz,
                                      int index)
        Returns an element at the given index or null if the index is out of bounds of this list.
      • reverse

        public static <E> void reverse​(List<E> thiz)
        Reverses elements in the list in-place.
      • optimizeReadOnlyList

        public static <E> List<E> optimizeReadOnlyList​(List<E> thiz)