public class ListUtil extends Object
| Constructor and Description |
|---|
ListUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <E> List<E> |
arrayAsList(E[] array)
Converts a given array to a list containing all elements of the original array.
|
static String |
arrayAsString(String[] array)
Returns a string, representing a given array of strings.
|
static String |
arrayAsString(String[] array,
String delimiter)
Returns a string, representing a given array of strings.
|
static Class<?>[] |
classListAsArray(List<Class<?>> list)
Converts a list of class references into an array of those class references.
|
static <E> List<E> |
copyItems(List<E> list,
int start,
int end)
Creates a new list from a range of elements of a given list.
|
static <E> E |
getFirstNonNullItem(List<E> list)
Gets a first non-null element of a given list.
|
static String |
intListAsString(List<Integer> list)
Returns a string, representing a given list of integers.
|
static String |
intListAsString(List<Integer> list,
String delimiter)
Returns a string, representing a given list of integers.
|
static <E> List<E> |
invert(List<E> list)
Returns a copy of the specified list in reverse order.
|
static String |
listAsString(List<String> list)
Returns a string, representing a given list of strings.
|
static String |
listAsString(List<String> list,
String delimiter)
Returns a string, representing a given list of strings.
|
static void |
listTrimTrail(List<String> list)
Remove empty trailing elements of the given list.
|
static List<String> |
listTrimValues(List<String> list)
Creates a list, containing all trimmed values of a given list of strings.
|
static List<String> |
loadList(Class<?> classRef,
String resourceLocation)
Creates a new list of strings and fills it with the data read from a given resource.
|
static void |
loadList(List<String> list,
Class<?> classRef,
String resourceLocation)
Fills in an existing list of strings with the data read from a given resource.
|
static String |
merge(List<String> list,
int start,
int end,
String joiner)
Merges specified items of a given string list into a single string.
|
static String |
merge(String[] array,
int start,
int end,
String joiner)
Merges specified elements of a given string array into a single string.
|
static <E> List<E> |
moveItems(List<E> buffer)
Moves all items from a given list to a newly created list.
|
static <E> List<E> |
moveItems(List<E> buffer,
int start,
int end)
Creates a new list and moves therein a range of elements from a given list.
|
static Object[] |
objectListAsArray(List<Object> list)
Converts a list of objects into an array of those objects.
|
static <E> void |
remove(List<E> list,
int start,
int end)
Removes a range of elements from a given list.
|
static String[] |
stringAsArray(String st)
Splits up a string of comma-separated substrings into an array of those substrings.
|
static String[] |
stringAsArray(String st,
String delimiter)
Splits up a string of comma-separated substrings into an array of those substrings.
|
static List<Integer> |
stringAsIntList(String st)
Converts a string of comma-separated numbers into a list of integers.
|
static List<Integer> |
stringAsIntList(String st,
String delimiter)
Converts a string of comma-separated numbers into a list of integers and sorts the list ascendantly.
|
static List<Integer> |
stringAsIntList(String st,
String delimiter,
boolean sortList)
Converts a string of comma-separated numbers into a list of integers.
|
static List<LocaleId> |
stringAsLanguageList(String input)
Splits up a string of comma-separated substrings representing locale codes into a
string list of
LocaleId objects. |
static void |
stringAsList(List<String> list,
String st)
Splits up a string of comma-separated substrings into a string list of those substrings.
|
static void |
stringAsList(List<String> list,
String st,
String delimiter)
Splits up a string of delimited substrings into a string list of those substrings.
|
static List<String> |
stringAsList(String st)
Splits up a string of comma-separated substrings into a string list of those substrings.
|
static List<String> |
stringAsList(String st,
char delimiter)
Splits up a string of delimited substrings into a string list of those substrings.
|
static List<String> |
stringAsList(String st,
String delimiter)
Splits up a string of delimited substrings into a string list of those substrings.
|
static String[] |
stringListAsArray(List<String> list)
Converts a list of strings into an array of those strings.
|
public static List<String> stringAsList(String st)
st - string of comma-separated substrings.public static List<LocaleId> stringAsLanguageList(String input)
LocaleId objects.input - string of comma-separated substrings.LocaleId objects.public static void stringAsList(List<String> list, String st)
list - a list to put the substrings.st - string of comma-separated substrings.public static List<String> stringAsList(String st, String delimiter)
st - string of delimited substrings.delimiter - a string delimiting substrings in the string.public static List<String> stringAsList(String st, char delimiter)
st - string of delimited substrings.delimiter - a character delimiting substrings in the string.public static void stringAsList(List<String> list, String st, String delimiter)
list - a list to put the substrings.st - string of delimited substrings.delimiter - a string delimiting substrings in the string.public static String[] stringAsArray(String st)
st - string of comma-separated substrings.public static String[] stringAsArray(String st, String delimiter)
st - string of comma-separated substrings.delimiter - a string delimiting substrings in the string.public static String merge(String[] array, int start, int end, String joiner)
array - the given array of strings.start - index of the start element to be merged.end - index of the end element (inclusive) to be merged.joiner - string to join elements in the resulting string.public static String merge(List<String> list, int start, int end, String joiner)
list - the given list of strings.start - index of the start item to be merged.end - index of the end item (inclusive) to be merged.joiner - string to join items in the resulting string.public static List<Integer> stringAsIntList(String st)
st - string of comma-separated numbers.public static List<Integer> stringAsIntList(String st, String delimiter)
st - string of comma-separated numbersdelimiter - a string delimiting numbers in the stringpublic static List<Integer> stringAsIntList(String st, String delimiter, boolean sortList)
st - string of comma-separated numbersdelimiter - a string delimiting numbers in the stringsortList - if the numbers in the resulting list should be sorted (ascendantly)public static void listTrimTrail(List<String> list)
list - the list to be trimmed.public static List<String> listTrimValues(List<String> list)
list - the given list of strings.public static String[] stringListAsArray(List<String> list)
list - List of strings.public static Class<?>[] classListAsArray(List<Class<?>> list)
list - List of class references.public static Object[] objectListAsArray(List<Object> list)
list - List of objects.public static <E> List<E> arrayAsList(E[] array)
E - the type of the array's element.array - the given array.public static String arrayAsString(String[] array)
array - the given array of strings.public static String arrayAsString(String[] array, String delimiter)
array - the given array of strings.delimiter - the given delimiter.public static String listAsString(List<String> list)
list - the given list of strings.public static String listAsString(List<String> list, String delimiter)
list - the given list of strings.delimiter - the given delimiter.public static String intListAsString(List<Integer> list)
list - the given list of integers.public static String intListAsString(List<Integer> list, String delimiter)
list - the given list of integers.delimiter - the given delimiter.public static <E> List<E> invert(List<E> list)
list - the list to reverse.public static <E> void remove(List<E> list, int start, int end)
E - the type of the list's element.list - the given list.start - the start index (inclusive) to be removed.end - the end index (exclusive) to be removed.public static <E> List<E> copyItems(List<E> list, int start, int end)
E - the type of the list's element.list - the given list.start - the start index (inclusive) to be included in the resulting list.end - the end index (exclusive) to be included in the resulting list.public static <E> List<E> moveItems(List<E> buffer, int start, int end)
E - the type of the list's element.buffer - the given list.start - the start index (inclusive) to be included in the resulting list.end - the end index (exclusive) to be included in the resulting list.public static <E> List<E> moveItems(List<E> buffer)
E - the type of the list's element.buffer - the given list.public static <E> E getFirstNonNullItem(List<E> list)
E - the type of the list's element.list - the given list.public static List<String> loadList(Class<?> classRef, String resourceLocation)
classRef - reference to a class associated with the given resource.resourceLocation - the name of resource.public static void loadList(List<String> list, Class<?> classRef, String resourceLocation)
list - the given list of strings.classRef - reference to a class associated with the given resource.resourceLocation - the name of resource.Copyright © 2021. All rights reserved.