public class CollectionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T> List<T> |
asList(Enumeration<T> enu)
Converts the elements found in the given Enumeration into a list.
|
static <T> List<T> |
asList(Iterator<T> itr)
Converts the elements found in the given Iterator into a list.
|
static <T> ArrayList<T> |
asList(T... strings)
Converts the elements passed into a list.
|
static <K,V> Map<K,V> |
asMap(K[] keys,
V[] values)
Converts the given pair of arrays into a map that maps each keys[i] to
the corresponding values[i].
|
static <K,V> Map<K,V> |
asMap(List<K> keys,
List<V> values)
Converts the given pair of lists into a map that maps each keys[i] to
the corresponding values[i].
|
static <K extends Comparable<? super K>,V> |
asMapSorted(K[] keys,
V[] values)
Converts the given pair of arrays into a sorted map that maps each
keys[i] to the corresponding values[i].
|
static <K extends Comparable<? super K>,V> |
asMapSorted(List<K> keys,
List<V> values)
Converts the given pair of arrays into a map that maps each keys[i] to
the corresponding values[i].
|
static <K> Set<K> |
asSet(K... values)
Converts the given values into a set.
|
static <K> Set<K> |
asSet(K value)
Converts the given values into a set.
|
static <K extends Comparable<K>> |
asSetSorted(K... values)
Converts the given values into a sorted set.
|
static <T> int |
indexOfSafe(List<T> list,
T value)
Returns the index of the given value in the given list,
using == to compare rather than .equals.
|
static String |
join(Collection<?> c)
Combines the elements of the given collection into a string separated
by commas.
|
static String |
join(Collection<?> c,
String separator)
Combines the elements of the given collection into a string separated
by the given separator.
|
static String |
join(Map<?,?> map)
Combines the elements of the given map into a string separated
by an equals sign between keys and their values, and commas between each entry.
|
static String |
join(Map<?,?> map,
String kvSeparator,
String elementSeparator)
Combines the elements of the given collection into a string separated
by the given kv separator between keys and their values, and
the given element separator commas between each entry.
|
public static <T> ArrayList<T> asList(T... strings)
public static <T> List<T> asList(Enumeration<T> enu)
public static <T> List<T> asList(Iterator<T> itr)
public static <K,V> Map<K,V> asMap(K[] keys, V[] values)
public static <K,V> Map<K,V> asMap(List<K> keys, List<V> values)
public static <K extends Comparable<? super K>,V> Map<K,V> asMapSorted(K[] keys, V[] values)
public static <K extends Comparable<? super K>,V> Map<K,V> asMapSorted(List<K> keys, List<V> values)
public static <K> Set<K> asSet(K value)
public static <K> Set<K> asSet(K... values)
public static <K extends Comparable<K>> Set<K> asSetSorted(K... values)
public static <T> int indexOfSafe(List<T> list, T value)
public static String join(Collection<?> c)
public static String join(Collection<?> c, String separator)
public static String join(Map<?,?> map)