public class OptionalListExtensions
extends java.lang.Object
List objects| Constructor and Description |
|---|
OptionalListExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static <T> java.util.Optional<T> |
getFirst(@NonNull java.util.List<T> list)
Returns an
Optional with the first object from the given List |
static <T> java.util.Optional<T> |
getLast(@NonNull java.util.List<T> list)
Returns an
Optional with the last object from the given List |
static <T> java.util.Optional<T> |
getNext(@NonNull java.util.List<T> list,
T element)
Gets the next element from the given
List. |
static <T> java.util.Optional<T> |
getPrevious(@NonNull java.util.List<T> list,
T element)
Gets the previous element from the given
List. |
static <T> java.util.Optional<T> |
removeFirst(@NonNull java.util.List<T> list)
Returns an
Optional with the first object if it was removed from the given
List |
static <T> java.util.Optional<T> |
removeLast(@NonNull java.util.List<T> list)
Returns an
Optional with the last object if it was removed from the given
List |
public static <T> java.util.Optional<T> getFirst(@NonNull
@NonNull java.util.List<T> list)
Optional with the first object from the given ListT - the generic type of the elementslist - the List objectOptional with the first object from the given List or an empty
Optional if the List is emptypublic static <T> java.util.Optional<T> getLast(@NonNull
@NonNull java.util.List<T> list)
Optional with the last object from the given ListT - the generic type of the elementslist - the List objectOptional with the last object from the given List or an empty
Optional if the List is emptypublic static <T> java.util.Optional<T> removeFirst(@NonNull
@NonNull java.util.List<T> list)
Optional with the first object if it was removed from the given
ListT - the generic type of the elementslist - the List objectOptional with the first object if it was removed from the given
List or an empty Optional if the List is emptypublic static <T> java.util.Optional<T> removeLast(@NonNull
@NonNull java.util.List<T> list)
Optional with the last object if it was removed from the given
ListT - the generic type of the elementslist - the List objectOptional with the last object if it was removed from the given
List or an empty Optional if the List is emptypublic static <T> java.util.Optional<T> getPrevious(@NonNull
@NonNull java.util.List<T> list,
T element)
List. As start point is the given elementT - the generic type of elementslist - the listelement - the elementOptional with the previous element from the given List or an empty
Optional if the List has no previous elementpublic static <T> java.util.Optional<T> getNext(@NonNull
@NonNull java.util.List<T> list,
T element)
List. As start point is the given elementT - the generic type of elementslist - the listelement - the elementOptional with the next element from the given List or an empty
Optional if the List has no next element