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 Tuple.leftValue, retrieves its Tuple.rightValue |
static boolean |
hasStringPairWithKey(List<StringPair> stringPairList,
String key)
Checks whether the given
stringPairList contains a StringPair instance with the given
key as its Tuple.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<?> list,
Class<T> type)
Converts a list of objects to a list of given type
|
static List<String> |
toStringList(List<?> 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<?> list)
list - the list of objects to be convertedString representationspublic static <T> List<T> toListOfType(List<?> list, Class<T> type)
T - the type of the elements in the resulting listlist - the list of objects to be convertedtype - type to be converted totypeIllegalArgumentException - 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 Tuple.leftValuestringPairList - List of StringPairs to be checkedkey - value to be checked as the left value of the matching StringPairtrue 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 Tuple.leftValue, retrieves its Tuple.rightValuestringPairList - List of StringPairs to be checkedkey - value to be checked as the left value of the matching StringPairOptional of type String containing the right value if a matching
StringPair is found, Optional.EMPTY otherwiseCopyright © 2016–2019 AdroitLogic. All rights reserved.