public class CollectionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> List<T> |
disorder(Collection<T> collection)
将给定的集合打乱,并全部添加到一个新的List,此操作不会影响传入的对象.
|
static <T> int |
getCount(Collection<T> collection) |
static <T> T |
getFirstNotNullValue(Collection<T> collection)
Returns the first not null element if the collection is not null and have
not null value, else return null.
|
static <T> T |
getFirstOrNull(Collection<T> collection)
Return either the first element when the collection is not null and empty
or null.
|
static <T> T |
getLastElement(Collection<T> collection) |
static boolean |
isCollection(Object collection)
Returns true if the collection is implements Collection; false otherwise.
|
static boolean |
isEmpty(Collection<?> collection)
Returns true if the collection is null or empty; false otherwise.
|
static boolean |
isNotEmpty(Collection<?> collection)
Returns true if the collection is both not null and not empty; false
otherwise.
|
static <T> String |
join(Collection<T> collection,
String separator)
按指定的分割符拼接集合里的元素。
|
static String |
join(Object collection,
String separator)
按指定的分割符拼接集合里的元素。
|
static <T> T[] |
toArray(Collection<T> collection)
Convert given collection to an array.
|
static <T> List<T> |
toList(Collection<T> collection)
Convert given collection to a list.
|
static <T> Set<T> |
toSet(Collection<T> collection)
Convert given collection to a set.
|
public static boolean isCollection(Object collection)
collection - the collection to be tested.public static boolean isEmpty(Collection<?> collection)
collection - the collection to be tested.public static boolean isNotEmpty(Collection<?> collection)
collection - the collection to be tested.public static <T> T getFirstOrNull(Collection<T> collection)
collection - the collection to handle.public static <T> T getFirstNotNullValue(Collection<T> collection)
collection - the collection to be handled.public static <T> List<T> toList(Collection<T> collection)
collection - source collection.public static <T> Set<T> toSet(Collection<T> collection)
collection - source collection.public static <T> T[] toArray(Collection<T> collection)
collection - source collection.public static <T> List<T> disorder(Collection<T> collection)
collection - 任意的集体类型。public static <T> T getLastElement(Collection<T> collection)
public static <T> int getCount(Collection<T> collection)
public static <T> String join(Collection<T> collection, String separator)
collection - 任意集合。separator - 分割符Copyright © 2014. All rights reserved.