public class ManifoldListCollectionExt extends Object
Constructor and Description |
---|
ManifoldListCollectionExt() |
Modifier and Type | Method and Description |
---|---|
static <E> E |
first(List<E> thiz)
Returns first element.
|
static <E> E |
firstOrNull(List<E> thiz)
Returns the first element, or null if the list is empty.
|
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. |
static <E> E |
last(List<E> thiz)
Returns the last element.
|
static <E> E |
last(List<E> thiz,
Predicate<E> predicate)
Returns the last element matching the given
predicate . |
static <E> E |
lastOrNull(List<E> thiz)
Returns the last element, or
null if the list is empty. |
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. |
static <E> List<E> |
optimizeReadOnlyList(List<E> thiz) |
static <E> void |
reverse(List<E> thiz)
Reverses elements in the list in-place.
|
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.
|
static <E> E |
singleOrNull(List<E> thiz)
Returns single element, or
null if the list is empty or has more than one element. |
public static <E> E first(List<E> thiz)
NoSuchElementException
- if the list is empty.public static <E> E firstOrNull(List<E> thiz)
public static <E> E last(List<E> thiz)
NoSuchElementException
- if the list is empty.public static <E> E last(List<E> thiz, Predicate<E> predicate)
predicate
.NoSuchElementException
- if no such element is found.public static <E> E lastOrNull(List<E> thiz)
null
if the list is empty.public static <E> E lastOrNull(List<E> thiz, Predicate<E> predicate)
predicate
, or null
if no such element was found.public static <E> E single(List<E> thiz)
public static <E> E singleOrNull(List<E> thiz)
null
if the list is empty or has more than one element.public static <E> E getOrNull(List<E> thiz, int index)
index
or null if the index
is out of bounds of this list.public static <E> void reverse(List<E> thiz)
Copyright © 2024. All rights reserved.