public class ListUtils extends Object
Constructor and Description |
---|
ListUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> List<T> |
cloneList(List<T> originalList)
Creates a clone of a given
List . |
static Optional<String> |
getStringPairValueWithKey(List<StringPair> stringPairList,
String key)
If the given
stringPairList contains a StringPair instance with the given
key as its StringPair.leftValue , retrieves its StringPair.rightValue |
static boolean |
hasStringPairWithKey(List<StringPair> stringPairList,
String key)
Checks whether the given
stringPairList contains a StringPair instance with the given
key as its StringPair.leftValue |
static <T> List<T> |
modifiableList(T... entries)
Creates a modifiable list from the given set of typed values in the entries
|
static <T> List<T> |
toListOfType(List<Object> list,
Class<T> type)
Converts a list of objects to a list of given type
|
static List<String> |
toStringList(List<Object> list)
Converts a list of objects to a list of their String representations
|
@SafeVarargs public static <T> List<T> modifiableList(T... entries)
T
- the type of the list entitiesentries
- the array of values to be initially included in the modifiable listpublic static List<String> toStringList(List<Object> list)
public static <T> List<T> toListOfType(List<Object> list, Class<T> type)
T
- the type of the elements in the resulting listlist
- the list of Object
to be convertedtype
- type to be converted totype
IllegalArgumentException
- if any of the objects in the list cannot be converted to the given typepublic static <T> List<T> cloneList(List<T> originalList)
List
. The original and cloned lists will refer separate objects for Java
immutable entries while both will refer the same objects for others.T
- the type of the valuesoriginalList
- the list to be clonedList
with the contents of the original list, or empty list if the original list
is nullpublic static boolean hasStringPairWithKey(List<StringPair> stringPairList, String key)
stringPairList
contains a StringPair
instance with the given
key
as its StringPair.leftValue
stringPairList
- List
of StringPair
s to be checkedkey
- value to be checked as the left value of the matching StringPair
true
if a matching instance of StringPair
found, false
otherwisepublic static Optional<String> getStringPairValueWithKey(List<StringPair> stringPairList, String key)
stringPairList
contains a StringPair
instance with the given
key
as its StringPair.leftValue
, retrieves its StringPair.rightValue
stringPairList
- List
of StringPair
s to be checkedkey
- value to be checked as the left value of the matching StringPair
Optional
of type String
containing the right value if a matching
StringPair
is found, Optional.EMPTY
otherwiseCopyright © 2016–2019 AdroitLogic. All rights reserved.