public class Collects extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
Collects.ListType |
static class |
Collects.MapType |
static class |
Collects.SetType |
| 构造器和说明 |
|---|
Collects() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <E> void |
addAll(Collection<E> collection,
E[] iterator) |
static <E> void |
addAll(Collection<E> collection,
Iterable<E> iterable) |
static <E> void |
addAll(Collection<E> collection,
Iterator<E> iterator) |
static <E> boolean |
allMatch(Iterable<E> collection,
Predicate<E> predicate)
whether all elements match the specified condition or not
|
static <K,V> boolean |
allMatch(Map<? extends K,? extends V> map,
Predicate2<K,V> predicate)
whether all elements match the specified condition or not
|
static <E> boolean |
anyMatch(Collection<E> collection,
Predicate<E> predicate)
has any element match the specified condition
|
static <K,V> boolean |
anyMatch(Map<? extends K,? extends V> map,
Predicate2<K,V> predicate)
has any element match the specified condition
|
static <E> Collection<E> |
asCollection(Iterable<E> iterable) |
static <E> Iterable<E> |
asIterable(Object object)
Convert any object to an immutable Iterable
|
static <E> Iterable<E> |
asIterable(Object object,
boolean mutable)
Convert any object to Iterable
|
static <E> List<E> |
asList(E[] array)
Convert an array to a ArrayList
|
static <E> List<E> |
asList(E[] array,
boolean mutable,
Collects.ListType listType)
Convert an array to a List, if the 'mutable' argument is true, will return an unmodifiable List
|
static <E> List<E> |
asList(E[] array,
Collects.ListType listType)
Convert an array to a ArrayList or a LinkedList
|
static <E> List<E> |
asList(Iterable<E> iterable) |
static <E> List<E> |
asList(Iterable<E> iterable,
boolean mutable) |
static <E> Collection<E> |
collect(Object anyObject,
Collection<E> container) |
static <E,R> R |
collect(Object anyObject,
Collector<E,R> collector) |
static <E,R> R |
collect(Object anyObject,
Supplier0<R> containerFactory,
Consumer2<R,E> consumer) |
static <E> Collection<E> |
concat(Collection<E> c1,
Collection<E> c2)
Concat two collection to one
|
static <E> Collection<E> |
concat(Collection<E> c1,
Collection<E> c2,
boolean newOne)
Concat two collection to one
|
static <E> int |
count(Collection<E> collection) |
static <K,V> int |
count(Map<K,V> map) |
static int |
count(Object anyObject) |
static <E> CollectionDiffResult<E> |
diff(Collection<E> oldCollection,
Collection<E> newCollection) |
static <E> CollectionDiffResult<E> |
diff(Collection<E> oldCollection,
Collection<E> newCollection,
Comparator<E> elementComparator) |
static <E> CollectionDiffResult<E> |
diff(Collection<E> oldCollection,
Collection<E> newCollection,
Comparator<E> elementComparator,
KeyBuilder<String,E> keyBuilder) |
static <K,V> MapDiffResult<K,V> |
diff(Map<K,V> oldMap,
Map<K,V> newMap) |
static <K,V> MapDiffResult<K,V> |
diff(Map<K,V> oldMap,
Map<K,V> newMap,
Comparator<V> valueComparator) |
static <K,V> MapDiffResult<K,V> |
diff(Map<K,V> oldMap,
Map<K,V> newMap,
Comparator<V> valueComparator,
Comparator<K> keyComparator) |
static <E> Set<E> |
distinct(Collection<E> collection) |
static <E> E[] |
emptyArray(Class<E> componentType) |
static <E> List<E> |
emptyArrayList()
Get a empty, mutable java.util.ArrayList
|
static <K,V> Map<K,V> |
emptyHashMap()
Get a empty, mutable java.util.HashMap
|
static <K,V> Map<K,V> |
emptyHashMap(boolean sequential)
Get a empty, mutable java.util.HashMap or java.util.LinkedHashMap
|
static <E> HashSet<E> |
emptyHashSet()
Get a empty, mutable java.util.HashSet
|
static <E> HashSet<E> |
emptyHashSet(boolean sequential)
Get a empty, mutable java.util.HashSet or java.util.LinkedHashSet
|
static <K,V> Hashtable |
emptyHashtable()
Get a empty, mutable java.util.Hashtable
|
static <E> List<E> |
emptyLinkedList()
Get a empty, mutable java.util.LinkedList
|
static <K,V> NonAbsentHashMap<K,V> |
emptyNonAbsentHashMap(Supplier<K,V> supplier) |
static <K,V> Map<K,V> |
emptyTreeMap()
Get a empty, mutable java.util.TreeMap
|
static <K,V> Map<K,V> |
emptyTreeMap(Comparator<K> comparator)
Get a empty, mutable java.util.TreeMap
|
static <E> TreeSet<E> |
emptyTreeSet()
Get a empty, mutable java.util.TreeSet
|
static <E> TreeSet<E> |
emptyTreeSet(Comparator<E> comparator) |
static <K,V> Map<K,V> |
filter(Map<K,V> map,
Predicate2<K,V> predicate)
Filter a map with the specified predicate
|
static <E> Collection<E> |
filter(Object anyObject,
Predicate<E> predicate)
Filter any object with the specified predicate
|
static <E> E |
findFirst(Collection<E> collection,
Predicate<E> predicate)
find the first matched element, null if not found
|
static <K,V> Map.Entry<? extends K,? extends V> |
findFirst(Map<? extends K,? extends V> map,
Predicate2<K,V> predicate)
find the first matched element, null if not found
|
static <E,R> Collection<R> |
flatMap(Collection<Collection<E>> collection,
Function<E,R> mapper)
map a collection to another, flat it
|
static <E> void |
forEach(E[] array,
Consumer2<Integer,E> consumer)
Iterate every element
|
static <K,V> void |
forEach(Map<? extends K,? extends V> map,
Consumer2<K,V> consumer)
Iterate every element
|
static <E> void |
forEach(Object anyObject,
Consumer<E> consumer)
Iterate every element
|
static <E> List<E> |
getEmptyListIfNull(List<E> list)
Avoid NPE, create an empty, new list when the specified list is null
|
static <E> List<E> |
getEmptyListIfNull(List<E> list,
Collects.ListType listType) |
static <K,V> Map<K,V> |
getEmptyMapIfNull(Map<K,V> map)
Create an empty map when the specified map is null.
|
static <K,V> Map<K,V> |
getEmptyMapIfNull(Map<K,V> map,
Collects.MapType mapType) |
static <E> Set<E> |
getEmptySetIfNull(Set<E> set)
Avoid NPE, create an empty, new set when the specified set is null
|
static <E> Set<E> |
getEmptySetIfNull(Set<E> set,
Collects.SetType setType) |
static <E> List<E> |
limit(Collection<E> collection,
int maxSize)
truncate a collection using subList(0, maxSize)
|
static <K,V,R> List<R> |
map(Map<? extends K,? extends V> map,
Function2<K,V,R> mapper)
mapping aMap to a list
|
static <K,V,K1,V1> |
map(Map<? extends K,? extends V> map,
Mapper2<K,V,Pair<K1,V1>> mapper)
mapping aMap to bMap
|
static <E,R> Collection<R> |
map(Object anyObject,
Function<E,R> mapper)
mapping an iterable to a list
|
static <E,K,V> Map<K,V> |
map(Object anyObject,
Mapper<E,Pair<K,V>> mapper)
mapping an iterable to a map
|
static <E> E |
max(Object object,
Comparator<E> comparator) |
static <E> Collection<E> |
merge(Collection<E> c1,
Collection<E> c2) |
static <E> Collection<E> |
merge(Collection<E> c1,
Collection<E> c2,
boolean newOne) |
static <K,V> Map<K,V> |
merge(Map<K,V> map1,
Map<K,V> map2) |
static <K,V> Map<K,V> |
merge(Map<K,V> map1,
Map<K,V> map2,
boolean newOne) |
static <E> E |
min(Object object,
Comparator<E> comparator) |
static <E> boolean |
noneMatch(Iterable<E> collection,
Predicate<E> predicate)
has no any element match the specified condition ?
|
static <K,V> boolean |
noneMatch(Map<? extends K,? extends V> map,
Predicate2<K,V> predicate)
has no any element match the specified condition ?
|
static Map<String,String> |
propertiesToStringMap(Properties properties) |
static Map<String,String> |
propertiesToStringMap(Properties properties,
boolean sort) |
static Map<String,String> |
propertiesToStringMap(Properties properties,
Comparator<String> keyComparator) |
static <E> boolean |
removeIf(Collection<E> collection,
Predicate<E> predicate)
remove all elements that match the condition
|
static <E> boolean |
removeIf(Iterator<E> iterator,
Predicate<E> predicate) |
static <K,V> boolean |
removeIf(Map<K,V> map,
Predicate2<K,V> predicate)
remove all elements that match the map
|
static <E> List<E> |
reverse(List<E> list,
boolean newOne)
Reverse a list, return an new list when the argument 'newOne' is true
|
static <E> List<E> |
skip(Collection<E> collection,
int n)
skip n elements, get a collection using subList(n, size)
|
static <E extends Comparable<E>> |
sort(Collection<E> collection,
boolean reverse)
sort a collection, return an new list. it is different to
Collections.sort(list) is that : Collections.sort() return void
|
static <E> TreeSet<E> |
sort(Collection<E> collection,
Comparator<E> comparator)
sort a collection, return an new list. it is different to
Collections.sort(list) is that : Collections.sort() return void
|
static <E> TreeSet<E> |
sort(Collection<E> collection,
Comparator<E> comparator,
boolean reverse)
sort a collection, return an new list. it is different to
Collections.sort(list) is that : Collections.sort() return void
|
static <K,V> Map<K,V> |
sort(Map<K,V> map,
Comparator<K> comparator)
sort a collection, return an new list. it is different to
Collections.sort(list) is that : Collections.sort() return void
|
static <E> Object[] |
toArray(Collection<E> list) |
static <E> E[] |
toArray(Collection<E> list,
Class<E[]> clazz)
Convert a list to an array
|
static <E,K,V> Collector<E,Map<K,V>> |
toHashMap(Function<E,K> keyMapper,
Function<E,V> valueMapper,
boolean sequential) |
static <E> Collector<E,HashSet<E>> |
toHashSet(boolean sequential) |
static <E> Collector<E,List<E>> |
toList() |
static <E,K,V> Collector<E,Map<K,V>> |
toTreeMap(Function<E,K> keyMapper,
Function<E,V> valueMapper,
Comparator<K> comparator) |
static <E> Collector<E,TreeSet<E>> |
toTreeSet(Comparator<E> comparator) |
static <K,V> WrappedNonAbsentMap<K,V> |
wrapAsNonAbsentMap(Map<K,V> map,
Supplier<K,V> supplier) |
public static <K,V> Hashtable emptyHashtable()
K - KeyV - Valuepublic static <K,V> Map<K,V> emptyTreeMap()
K - KeyV - Valuepublic static <K,V> Map<K,V> emptyTreeMap(@Nullable Comparator<K> comparator)
K - KeyV - Valuepublic static <K,V> Map<K,V> emptyHashMap()
K - KeyV - Valuepublic static <K,V> Map<K,V> emptyHashMap(boolean sequential)
K - KeyV - Valuepublic static <K,V> NonAbsentHashMap<K,V> emptyNonAbsentHashMap(@NonNull Supplier<K,V> supplier)
public static <K,V> WrappedNonAbsentMap<K,V> wrapAsNonAbsentMap(Map<K,V> map, Supplier<K,V> supplier)
public static <E> HashSet<E> emptyHashSet()
E - Elementpublic static <E> HashSet<E> emptyHashSet(boolean sequential)
E - Elementpublic static <E> TreeSet<E> emptyTreeSet()
E - Elementpublic static <E> TreeSet<E> emptyTreeSet(@Nullable Comparator<E> comparator)
public static <E> List<E> emptyArrayList()
E - Elementpublic static <E> List<E> emptyLinkedList()
E - Elementpublic static <K,V> Map<K,V> getEmptyMapIfNull(@Nullable Map<K,V> map)
public static <K,V> Map<K,V> getEmptyMapIfNull(@Nullable Map<K,V> map, @Nullable Collects.MapType mapType)
public static <E> Set<E> getEmptySetIfNull(@Nullable Set<E> set)
public static <E> Set<E> getEmptySetIfNull(@Nullable Set<E> set, @Nullable Collects.SetType setType)
getEmptySetIfNull(Set)public static <E> List<E> getEmptyListIfNull(@Nullable List<E> list)
public static <E> List<E> getEmptyListIfNull(@Nullable List<E> list, @Nullable Collects.ListType listType)
getEmptyListIfNull(List)public static <E> List<E> asList(@Nullable E[] array, @Nullable Collects.ListType listType)
public static <E> List<E> asList(@Nullable E[] array, boolean mutable, @Nullable Collects.ListType listType)
public static <E> Collection<E> asCollection(@Nullable Iterable<E> iterable)
public static <E> Object[] toArray(@Nullable Collection<E> list)
public static <E> E[] toArray(@Nullable Collection<E> list, @Nullable Class<E[]> clazz)
public static <E> Iterable<E> asIterable(@Nullable Object object)
public static <E> Iterable<E> asIterable(@Nullable Object object, boolean mutable)
public static <E> Collection<E> filter(@Nullable Object anyObject, @NonNull Predicate<E> predicate)
public static <K,V> Map<K,V> filter(@Nullable Map<K,V> map, @NonNull Predicate2<K,V> predicate)
public static <E,R> Collection<R> map(@Nullable Object anyObject, @NonNull Function<E,R> mapper)
public static <E,K,V> Map<K,V> map(@Nullable Object anyObject, @NonNull Mapper<E,Pair<K,V>> mapper)
public static <K,V,R> List<R> map(@Nullable Map<? extends K,? extends V> map, @NonNull Function2<K,V,R> mapper)
public static <K,V,K1,V1> Map<K1,V1> map(@Nullable Map<? extends K,? extends V> map, @NonNull Mapper2<K,V,Pair<K1,V1>> mapper)
public static <E,R> Collection<R> flatMap(@Nullable Collection<Collection<E>> collection, @NonNull Function<E,R> mapper)
public static <E> void forEach(@Nullable Object anyObject, @NonNull Consumer<E> consumer)
public static <E> void forEach(@Nullable E[] array, @NonNull Consumer2<Integer,E> consumer)
public static <K,V> void forEach(@Nullable Map<? extends K,? extends V> map, @NonNull Consumer2<K,V> consumer)
public static <E> E findFirst(@Nullable Collection<E> collection, @Nullable Predicate<E> predicate)
public static <K,V> Map.Entry<? extends K,? extends V> findFirst(@Nullable Map<? extends K,? extends V> map, @Nullable Predicate2<K,V> predicate)
public static <E> boolean removeIf(@Nullable Collection<E> collection, @NonNull Predicate<E> predicate)
UnsupportedOperationException, - NullPointExceptionpublic static <E> boolean removeIf(@Nullable Iterator<E> iterator, @NonNull Predicate<E> predicate)
public static <K,V> boolean removeIf(@Nullable Map<K,V> map, @NonNull Predicate2<K,V> predicate)
UnsupportedOperationException, - NullPointExceptionpublic static <E> boolean anyMatch(@Nullable Collection<E> collection, @NonNull Predicate<E> predicate)
public static <K,V> boolean anyMatch(@Nullable Map<? extends K,? extends V> map, @NonNull Predicate2<K,V> predicate)
public static <E> boolean allMatch(@Nullable Iterable<E> collection, @NonNull Predicate<E> predicate)
public static <K,V> boolean allMatch(@Nullable Map<? extends K,? extends V> map, @NonNull Predicate2<K,V> predicate)
public static <E> boolean noneMatch(@Nullable Iterable<E> collection, @NonNull Predicate<E> predicate)
public static <K,V> boolean noneMatch(@Nullable Map<? extends K,? extends V> map, @NonNull Predicate2<K,V> predicate)
public static <E> Set<E> distinct(@Nullable Collection<E> collection)
public static <E> List<E> limit(@Nullable Collection<E> collection, int maxSize)
public static <E> List<E> skip(@Nullable Collection<E> collection, int n)
public static <E extends Comparable<E>> TreeSet<E> sort(@Nullable Collection<E> collection, boolean reverse)
public static <E> TreeSet<E> sort(@Nullable Collection<E> collection, @NonNull Comparator<E> comparator)
public static <E> TreeSet<E> sort(@Nullable Collection<E> collection, @NonNull Comparator<E> comparator, boolean reverse)
public static <K,V> Map<K,V> sort(@Nullable Map<K,V> map, @NonNull Comparator<K> comparator)
public static <E> List<E> reverse(@Nullable List<E> list, boolean newOne)
public static <E> int count(@Nullable Collection<E> collection)
public static <E> E max(@NonNull Object object, @NonNull Comparator<E> comparator)
public static <E> E min(@Nullable Object object, @NonNull Comparator<E> comparator)
public static <E,R> R collect(@Nullable Object anyObject, @NonNull Collector<E,R> collector)
public static <E,R> R collect(@Nullable Object anyObject, @NonNull Supplier0<R> containerFactory, @NonNull Consumer2<R,E> consumer)
public static <E> Collection<E> collect(@Nullable Object anyObject, @NonNull Collection<E> container)
public static <E> CollectionDiffResult<E> diff(@Nullable Collection<E> oldCollection, @Nullable Collection<E> newCollection)
public static <E> CollectionDiffResult<E> diff(@Nullable Collection<E> oldCollection, @Nullable Collection<E> newCollection, @Nullable Comparator<E> elementComparator)
public static <E> CollectionDiffResult<E> diff(@Nullable Collection<E> oldCollection, @Nullable Collection<E> newCollection, @Nullable Comparator<E> elementComparator, @Nullable KeyBuilder<String,E> keyBuilder)
public static <K,V> MapDiffResult<K,V> diff(@Nullable Map<K,V> oldMap, @Nullable Map<K,V> newMap)
public static <K,V> MapDiffResult<K,V> diff(@Nullable Map<K,V> oldMap, @Nullable Map<K,V> newMap, @Nullable Comparator<V> valueComparator)
public static <K,V> MapDiffResult<K,V> diff(@Nullable Map<K,V> oldMap, @Nullable Map<K,V> newMap, @Nullable Comparator<V> valueComparator, @Nullable Comparator<K> keyComparator)
public static Map<String,String> propertiesToStringMap(@Nullable Properties properties)
public static Map<String,String> propertiesToStringMap(@Nullable Properties properties, boolean sort)
public static Map<String,String> propertiesToStringMap(@Nullable Properties properties, @Nullable Comparator<String> keyComparator)
public static <E> Collector<E,TreeSet<E>> toTreeSet(@Nullable Comparator<E> comparator)
public static <E,K,V> Collector<E,Map<K,V>> toHashMap(@NonNull Function<E,K> keyMapper, @NonNull Function<E,V> valueMapper, boolean sequential)
public static <E,K,V> Collector<E,Map<K,V>> toTreeMap(@NonNull Function<E,K> keyMapper, @NonNull Function<E,V> valueMapper, @Nullable Comparator<K> comparator)
public static <E> void addAll(Collection<E> collection, Iterable<E> iterable)
public static <E> void addAll(Collection<E> collection, E[] iterator)
public static <E> void addAll(Collection<E> collection, Iterator<E> iterator)
public static <E> Collection<E> concat(@Nullable Collection<E> c1, @Nullable Collection<E> c2)
public static <E> Collection<E> concat(@Nullable Collection<E> c1, @Nullable Collection<E> c2, boolean newOne)
public static <E> Collection<E> merge(@Nullable Collection<E> c1, @Nullable Collection<E> c2)
public static <E> Collection<E> merge(@Nullable Collection<E> c1, @Nullable Collection<E> c2, boolean newOne)
Copyright © 2019. All rights reserved.