public class ListUtils extends Object
Using a null
list is supported and will almost always return the default value
(e.g. false
, or null
).
Modifier and Type | Method and Description |
---|---|
static <T> boolean |
listContains(List<T> list,
T needle)
Return true if the
list contains the needle . |
static <T> boolean |
listElementsEqualTo(List<T> list,
T single)
Return
true if the list is only a single element equal to
single . |
static <T> T |
listSelectFirstFrom(List<T> list,
T[] choices)
Return the first item from
choices that is contained in the list . |
static <T> String |
listToString(List<T> list)
Return a human-readable representation of a list (non-recursively).
|
public static <T> boolean listContains(List<T> list, T needle)
list
contains the needle
.public static <T> boolean listElementsEqualTo(List<T> list, T single)
true
if the list
is only a single element equal to
single
.public static <T> String listToString(List<T> list)
public static <T> T listSelectFirstFrom(List<T> list, T[] choices)
choices
that is contained in the list
.
Choices with an index closer to 0 get higher priority. If none of the choices
are in the list
, then null
is returned.
list
- a list of objects which may or may not contain one or more of the choiceschoices
- an array of objects which should be used to select an item fromchoices
contained in list
, otherwise null