public class Collects extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
Collects.ListType |
static class |
Collects.MapType |
static class |
Collects.SetType |
| 构造器和说明 |
|---|
Collects() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <E,C extends Collection<E>> |
addAll(C dest,
E... iterator) |
static <E,C extends Collection<E>> |
addAll(C dest,
Iterable<E> iterable) |
static <E,C extends Collection<E>> |
addAll(C dest,
Iterator<E> iterator) |
static <E1,C1 extends Collection<E1>,E2,C2 extends Collection<E2>> |
addTo(C1 srcCollection,
C2 targetCollection,
Function<E1,E2> mapper) |
static <E,C extends Collection<E>> |
addTo(C srcCollection,
C targetCollection) |
static <E,C extends Collection<E>> |
allMatch(C collection,
Predicate<E> predicate)
whether all elements match the specified condition or not
|
static <K,V,M extends Map<? extends K,? extends V>> |
allMatch(M map,
Predicate2<K,V> predicate)
whether all elements match the specified condition or not
|
static boolean |
allMatch(Predicate predicate,
Object... collection) |
static <E,C extends Collection<E>> |
anyMatch(C collection,
Predicate<E> predicate)
has any element match the specified condition
|
static <K,V,M extends Map<? extends K,? extends V>> |
anyMatch(M map,
Predicate2<K,V> predicate)
has any element match the specified condition
|
static boolean |
anyMatch(Predicate<Object> predicate,
Object... array) |
static <E> E |
apply(E input,
Function<E,E>... mappers) |
static <E,C extends Collection<E>> |
asArray(C list,
Class<E> componentClass) |
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> Set<E> |
asSet(E... array)
Convert an array to a ArrayList
|
static <E> Set<E> |
asSet(E[] array,
boolean mutable,
Collects.SetType setType)
Convert an array to a List, if the 'mutable' argument is true, will return an unmodifiable List
|
static <E> Set<E> |
asSet(E[] array,
Collects.SetType setType)
Convert an array to a ArrayList or a LinkedList
|
static <E> Set<E> |
asSet(Iterable<E> iterable) |
static <E> Set<E> |
asSet(Iterable<E> iterable,
boolean mutable) |
static <E,C extends Collection<E>> |
clearNulls(C collection) |
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,C extends Collection<E>> |
concat(C c1,
C c2)
Concat two collection to one
|
static <E,C extends Collection<E>> |
concat(C c1,
C c2,
boolean newOne)
Concat two collection to one
|
static <E> boolean |
contains(Collection<E> collection,
E obj) |
static <E> boolean |
contains(Collection<E> collection,
E obj,
Predicate<E> predicate) |
static <E> boolean |
contains(E[] collection,
E obj) |
static <E> boolean |
contains(E[] collection,
E obj,
Predicate<E> predicate) |
static <E,C1 extends Collection<E>,C2 extends Collection<E>> |
containsAll(C1 c1,
C2 c2)
test c1 contains all elements in c2
|
static <E,C1 extends Collection<E>,C2 extends Collection<E>> |
containsAny(C1 c1,
C2 c2)
test c1 contains any element in c2
|
static <E,C1 extends Collection<E>,C2 extends Collection<E>> |
containsNone(C1 c1,
C2 c2)
test c1 contains all elements in c2
|
static <K,V> Map<K,V> |
copy(Map<K,V> source)
Clones a map.
|
static <E,C extends Collection<E>> |
count(C collection) |
static <K,V> int |
count(Map<K,V> map) |
static int |
count(Object anyObject) |
static <E,C extends Collection<E>> |
diff(C oldCollection,
C newCollection) |
static <E,C extends Collection<E>> |
diff(C oldCollection,
C newCollection,
Comparator<E> elementComparator) |
static <E,C extends Collection<E>> |
diff(C oldCollection,
C newCollection,
Comparator<E> elementComparator,
KeyBuilder<String,E> keyBuilder) |
static <K,V,M extends Map<K,V>> |
diff(M oldMap,
M newMap) |
static <K,V,M extends Map<K,V>> |
diff(M oldMap,
M newMap,
Comparator<V> valueComparator) |
static <K,V,M extends Map<K,V>> |
diff(M oldMap,
M newMap,
Comparator<V> valueComparator,
Comparator<K> keyComparator) |
static <X,Y,E,C extends Collection<E>> |
diff(X oldObject,
Function<X,E> oldMapper,
Y newObject,
Function<Y,E> newMapper) |
static <X,Y,E,C extends Collection<E>> |
diff(X oldObject,
Function<X,E> oldMapper,
Y newObject,
Function<Y,E> newMapper,
Comparator<E> elementComparator) |
static <X,Y,E,C extends Collection<E>> |
diff(X oldObject,
Function<X,E> oldMapper,
Y newObject,
Function<Y,E> newMapper,
Comparator<E> elementComparator,
KeyBuilder<String,E> keyBuilder) |
static <E,C extends Collection<E>> |
distinct(C collection) |
static <E> E[] |
emptyArray(Class<E> componentType) |
static <E> List<E> |
emptyArrayList()
Get a empty, mutable java.util.ArrayList
|
static <K,V> HashMap<K,V> |
emptyHashMap()
Get a empty, mutable java.util.HashMap
|
static <K,V> HashMap<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> LinkedList<E> |
emptyLinkedList()
Get a empty, mutable java.util.LinkedList
|
static <K,V> NonAbsentHashMap<K,V> |
emptyNonAbsentHashMap(Supplier<K,V> supplier) |
static <K,V> TreeMap<K,V> |
emptyTreeMap()
Get a empty, mutable java.util.TreeMap
|
static <K,V> TreeMap<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> Collection<E> |
filter(Object anyObject,
Predicate<E> consumePredicate,
Predicate<E> breakPredicate)
Filter any object with the specified predicate
|
static <E> Collection<E> |
filter(Object anyObject,
Predicate2<Integer,E> consumePredicate,
Predicate2<Integer,E> breakPredicate)
Filter any object with the specified predicate
|
static <E,C extends Collection<E>> |
findFirst(C collection)
find the first matched element, null if not found
|
static <E,C extends Collection<E>> |
findFirst(C 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,C extends Collection<E>> |
findN(C collection,
Predicate<E> predicate,
int n)
find the first matched element, null if not found
|
static <K,V> Map<? extends K,? extends V> |
findN(Map<? extends K,? extends V> map,
Predicate2<K,V> predicate,
int n)
find the first matched element, null if not found
|
static <E,C extends Collection<E>> |
findNPairs(C collection,
Predicate2<Integer,E> predicate,
int n)
find the first matched element, null if not found
|
static <E,C extends Iterable<E>,O> |
firstMap(C collection,
Function2<Integer,E,O> mapper)
find the first matched element, null if not found
|
static <E,C extends Iterable<E>,O> |
firstMap(C collection,
Function2<Integer,E,O> mapper,
Predicate<O> breakPredicate)
map every element in the collection with the mapper,
break the traverse if the mapped result match the breakPredicate
return the mapped result
|
static <E,C extends Iterable<E>,O> |
firstMap(C collection,
Function2<Integer,E,O> mapper,
Predicate2<E,O> breakPredicate)
map every element in the collection with the mapper,
break the traverse if the mapped result match the breakPredicate
return the mapped result
|
static <K,V,O> O |
firstMap(Map<K,V> map,
Function2<K,V,O> mapper)
find the first matched element, null if not found
|
static <K,V,O> O |
firstMap(Map<K,V> map,
Function2<K,V,O> mapper,
Predicate<O> breakPredicate)
find the first matched element, null if not found
|
static <E,C extends Collection<E>> |
firstOccurrence(C c,
E item) |
static <E,C extends Collection<E>> |
firstOccurrence(C c,
Predicate2<Integer,E> predicate) |
static <E> Collection<E> |
flat(Collection<Collection<E>> collections) |
static <E,R,C extends Collection<? extends Iterable<E>>> |
flatMap(C collection,
Function<E,R> mapper)
map a collection to another, flat it
|
static <E,R> Collection<R> |
flatMap(Function<E,R> mapper,
Collection<E[]> collection)
map a collection to another, flat it
|
static <E,C extends Iterable<E>> |
forEach(C collection,
Consumer<E> consumer) |
static <E,C extends Iterable<E>> |
forEach(C collection,
Consumer<E> consumer,
Predicate<E> breakPredicate) |
static <E,C extends Iterable<E>> |
forEach(C collection,
Consumer2<Integer,E> consumer)
Iterate every element
|
static <E,C extends Collection<E>> |
forEach(C collection,
Consumer2<Integer,E> consumer) |
static <E,C extends Iterable<E>> |
forEach(C collection,
Consumer2<Integer,E> consumer,
Predicate2<Integer,E> breakPredicate)
Iterate every element
|
static <E,C extends Iterable<E>> |
forEach(C collection,
Predicate<E> consumePredicate,
Consumer<E> consumer) |
static <E,C extends Iterable<E>> |
forEach(C collection,
Predicate<E> consumePredicate,
Consumer<E> consumer,
Predicate<E> breakPredicate)
Consume every element what matched the consumePredicate
|
static <E,C extends Iterable<E>> |
forEach(C collection,
Predicate2<Integer,E> consumePredicate,
Consumer2<Integer,E> consumer)
Consume every element what matched the consumePredicate
|
static <E,C extends Iterable<E>> |
forEach(C collection,
Predicate2<Integer,E> consumePredicate,
Consumer2<Integer,E> consumer,
Predicate2<Integer,E> breakPredicate)
Consume every element what matched the consumePredicate
|
static <E> void |
forEach(E[] array,
Consumer<E> consumer) |
static <E> void |
forEach(E[] array,
Consumer2<Integer,E> consumer)
Iterate every element
|
static <E> void |
forEach(E[] array,
Consumer2<Integer,E> consumer,
Predicate2<Integer,E> breakPredicate)
Iterate every element
|
static <E> void |
forEach(E[] array,
Predicate<E> consumePredicate,
Consumer<E> consumer,
Predicate<E> breakPredicate)
consume every element that matched the consumePredicate
|
static <E> void |
forEach(E[] array,
Predicate2<Integer,E> consumePredicate,
Consumer2<Integer,E> consumer)
consume every element that matched the consumePredicate
|
static <E> void |
forEach(E[] array,
Predicate2<Integer,E> consumePredicate,
Consumer2<Integer,E> consumer,
Predicate2<Integer,E> breakPredicate)
consume every element that matched the consumePredicate
|
static <K,V,M extends Map<? extends K,? extends V>> |
forEach(M map,
Consumer2<K,V> consumer)
Iterate every element
|
static <K,V,M extends Map<? extends K,? extends V>> |
forEach(M map,
Consumer2<K,V> consumer,
Predicate2<K,V> breakPredicate)
Iterate every element
|
static <K,V,M extends Map<? extends K,? extends V>> |
forEach(M map,
Predicate2<K,V> consumePredicate,
Consumer2<K,V> consumer)
consume every element what matched the consumePredicate
|
static <K,V,M extends Map<? extends K,? extends V>> |
forEach(M map,
Predicate2<K,V> consumePredicate,
Consumer2<K,V> consumer,
Predicate2<K,V> breakPredicate)
consume every element what matched the consumePredicate
|
static <E> void |
forEach(Object obj,
Consumer<E> consumer) |
static <E> void |
forEach(Object obj,
Consumer2<Integer,E> consumer) |
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 <K,E,C extends Collection<E>> |
groupBy(C iterable,
Function<E,K> classifier) |
static <K,E> Map<K,List<E>> |
groupBy(E[] iterable,
Function<E,K> classifier) |
static <K,E> Map<K,List<E>> |
groupBy(E[] iterable,
Function<E,K> classifier,
Supplier0<Map<K,List<E>>> mapFactory) |
static <K,E,C extends Collection<E>> |
groupBy(Iterable<E> iterable,
Function<E,K> classifier,
Supplier0<Map<K,List<E>>> mapFactory) |
static <E,K> Collector<E,Map<K,List<E>>> |
groupingBy(Function<E,K> classifier,
Supplier0<Map<K,List<E>>> mapFactory) |
static <E,K> Collector<E,Map<K,List<E>>> |
groupingBy(Function2<Integer,E,K> classifier,
Supplier0<Map<K,List<E>>> mapFactory) |
static <E> List<E> |
immutableArrayList(E... array) |
static <T> Enumeration<T> |
immutableEmptyEnumeration() |
static <E> List<E> |
immutableList() |
static <E> List<E> |
immutableList(List<E> list) |
static <K,V> Map<K,V> |
immutableMap() |
static <K,V> Map<K,V> |
immutableMap(Map<K,V> m) |
static <E> Set<E> |
immutableSet() |
static <E> Set<E> |
immutableSet(Set<E> set) |
static <E> int |
indexOf(E[] list,
E e) |
static <E> int |
indexOf(E[] list,
E e,
int startIndex) |
static <E> int |
indexOf(E[] list,
E e,
int startIndex,
int endIndex) |
static <E> int |
indexOf(List<E> list,
E e) |
static <E> int |
indexOf(List<E> list,
E e,
int startIndex) |
static <E> int |
indexOf(List<E> list,
E e,
int startIndex,
int endIndex)
[startIndex, endIndex)
|
static <E,C1 extends Collection<E>,C2 extends Collection<E>> |
intersection(C1 c1,
C2 c2) |
static <E> boolean |
isFirst(E obj,
Iterable<E> list) |
static <E> boolean |
isFirst(E obj,
List<E> list) |
static <E> boolean |
isFirst(E obj,
SortedSet<E> set) |
static <E> boolean |
isLast(E obj,
Iterable<E> list) |
static <E> boolean |
isLast(E obj,
List<E> list) |
static <E> boolean |
isLast(E obj,
SortedSet<E> set) |
static <E> int |
lastIndexOf(E[] list,
E e) |
static <E> int |
lastIndexOf(E[] list,
E e,
int startIndex) |
static <E> int |
lastIndexOf(E[] list,
E e,
int startIndex,
int endIndex) |
static <E> int |
lastIndexOf(List<E> list,
E e) |
static <E> int |
lastIndexOf(List<E> list,
E e,
int startIndex) |
static <E> int |
lastIndexOf(List<E> list,
E e,
int startIndex,
int endIndex)
[startIndex, endIndex)
|
static <E,C extends Collection<E>> |
limit(C collection,
int maxSize)
truncate a collection using subList(0, maxSize)
|
static <E> E[] |
limit(E[] array,
int maxSize) |
static <K,V,R,M extends Map<K,V>> |
map(M map,
Function2<K,V,R> mapper)
mapping aMap to a list
|
static <K,V,K1,V1,M extends Map<K,V>> |
map(M 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,M extends 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,C extends Collection<E>> |
merge(C c1,
C c2) |
static <E,C extends Collection<E>> |
merge(C c1,
C c2,
boolean newOne) |
static <K,V,M extends Map<K,V>> |
merge(M map1,
M map2) |
static <K,V,M extends Map<K,V>> |
merge(M map1,
M map2,
boolean newOne) |
static <E> E |
min(Object object,
Comparator<E> comparator) |
static <E> ArrayList<E> |
newArrayList(E... elements) |
static <E> ArrayList<E> |
newArrayList(Iterable<E> elements) |
static <K,V> ConcurrentHashMap<K,V> |
newConcurrentHashMap() |
static <K,V> HashMap<K,V> |
newHashMap(Map<K,V> map) |
static <E> HashSet<E> |
newHashSet(E... elements) |
static <E> HashSet<E> |
newHashSet(Iterable<E> elements) |
static <E> LinkedHashSet<E> |
newLinkedHashSet(E... elements) |
static <E> LinkedHashSet<E> |
newLinkedHashSet(Iterable<E> elements) |
static <E> LinkedList<E> |
newLinkedList(E... elements) |
static <E> LinkedList<E> |
newLinkedList(Iterable<E> elements) |
static <K,V> TreeMap<K,V> |
newTreeMap(Map<K,V> map) |
static <K,V> TreeMap<K,V> |
newTreeMap(Map<K,V> map,
Comparator<K> keyComparator) |
static <E> TreeSet<E> |
newTreeSet(E... elements) |
static <E> TreeSet<E> |
newTreeSet(Iterable<E> elements) |
static <E,C extends Collection<E>> |
noneMatch(C collection,
Predicate<E> predicate)
has no any element match the specified condition ?
|
static <K,V,M extends Map<? extends K,? extends V>> |
noneMatch(M map,
Predicate2<K,V> predicate)
has no any element match the specified condition ?
|
static boolean |
noneMatch(Predicate predicate,
Object... collection) |
static <E,K> List<List<E>> |
partitionBy(E[] c,
Function<E,K> classifier) |
static <E,K> List<List<E>> |
partitionBy(E[] c,
Function2<Integer,E,K> classifier) |
static <E,K> List<List<E>> |
partitionBy(Iterable<E> c,
Function<E,K> classifier) |
static <E,K> List<List<E>> |
partitionBy(Iterable<E> c,
Function2<Integer,E,K> classifier) |
static <E,K> List<List<E>> |
partitionBy(Iterator<E> c,
Function<E,K> classifier) |
static <E,K> List<List<E>> |
partitionBy(Iterator<E> c,
Function2<Integer,E,K> classifier) |
static <E> List<List<E>> |
partitionByCount(Iterable<E> c,
int partitionCount)
第二个参数为分区总数,不是单个分区中的数据量
|
static <E> List<List<E>> |
partitionBySize(Iterable<E> c,
int partitionSize)
第二个参数为单个分区中的数据量
|
static <E,K> Collector<E,Map<K,List<E>>> |
partitioningBy(Function<E,K> classifier) |
static <E,K> Collector<E,Map<K,List<E>>> |
partitioningBy(Function2<Integer,E,K> classifier) |
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> E |
reduce(E[] iterable,
Operator2<E> operator) |
static <E,C extends Iterable<E>> |
reduce(Iterable<E> iterable,
Operator2<E> operator) |
static <E,C extends Collection<E>> |
removeIf(C 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) |
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> void |
shuffle(List<E> list)
Randomly permutes the specified list using a default source of
randomness.
|
static <E> void |
shuffle(List<E> list,
Random rnd)
Randomly permute the specified list using the specified source of
randomness.
|
static <E,C extends Collection<E>> |
skip(C collection,
int n)
skip n elements, get a collection using subList(n, size)
|
static <E> E[] |
skip(E[] array,
int n) |
static <E extends Comparable<E>,C extends Collection<E>> |
sort(C 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,C extends Collection<E>> |
sort(C 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,C extends Collection<E>> |
sort(C 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,M extends Map<K,V>> |
sort(M 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> void |
swap(E[] arr,
int i,
int j)
Swaps the two specified elements in the specified array.
|
static <E> void |
swap(List<E> list,
int i,
int j)
Swaps the elements at the specified positions in the specified list.
|
static <E,C extends Collection<E>> |
toArray(C collection) |
static <E,C extends Collection<E>> |
toArray(C 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>> |
toMap(Supplier0<Map<K,V>> mapFactory,
Function<E,K> keyMapper,
Function<E,V> valueMapper) |
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)
Collector Factory:
|
static <E,C1 extends Collection<E>,C2 extends Collection<E>> |
union(C1 c1,
C2 c2) |
static <E> List<E> |
unmodifiableArrayList(E... elements) |
static <E> List<E> |
unmodifiableArrayList(List<E> list) |
static <K,V> Map<K,V> |
unmodifiableMap(Map<K,V> map) |
static <E> Set<E> |
unmodifiableSet(Collection<E> collection) |
static <E> Set<E> |
unmodifiableSet(E... elements) |
static <K,V> WrappedNonAbsentMap<K,V> |
wrapAsNonAbsentMap(Map<K,V> map,
Supplier<K,V> supplier) |
public static <T> Enumeration<T> immutableEmptyEnumeration()
public static <K,V> Hashtable emptyHashtable()
K - KeyV - Valuepublic static <K,V> TreeMap<K,V> emptyTreeMap()
K - KeyV - Valuepublic static <K,V> TreeMap<K,V> emptyTreeMap(@Nullable Comparator<K> comparator)
K - KeyV - Valuepublic static <K,V> Map<K,V> immutableMap()
public static <K,V> HashMap<K,V> emptyHashMap()
K - KeyV - Valuepublic static <K,V> HashMap<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(@NonNull Map<K,V> map, @NonNull Supplier<K,V> supplier)
public static <E> Set<E> immutableSet()
public static <E> HashSet<E> emptyHashSet()
E - Elementpublic static <E> Set<E> unmodifiableSet(Collection<E> collection)
public static <E> Set<E> unmodifiableSet(E... elements)
public 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> unmodifiableArrayList(E... elements)
public static <E> List<E> emptyArrayList()
E - Elementpublic static <E> List<E> immutableList()
public static <E> List<E> immutableArrayList(E... array)
public static <E> LinkedList<E> emptyLinkedList()
E - Elementpublic static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap()
public static <E> LinkedList<E> newLinkedList(@Nullable Iterable<E> elements)
public static <E> LinkedList<E> newLinkedList(@Nullable E... elements)
public static <E> LinkedHashSet<E> newLinkedHashSet(@Nullable Iterable<E> elements)
public static <E> LinkedHashSet<E> newLinkedHashSet(@Nullable E... elements)
public static <K,V> TreeMap<K,V> newTreeMap(Map<K,V> map, Comparator<K> keyComparator)
public 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> Set<E> asSet(@Nullable E[] array, @Nullable Collects.SetType setType)
public static <E> Set<E> asSet(@Nullable E[] array, boolean mutable, @Nullable Collects.SetType setType)
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,C extends Collection<E>> Object[] toArray(@Nullable C collection)
public static <E,C extends Collection<E>> E[] asArray(@Nullable C list, @NonNull Class<E> componentClass)
public static <E,C extends Collection<E>> E[] toArray(@Nullable C 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 <E> Collection<E> filter(@Nullable Object anyObject, @Nullable Predicate<E> consumePredicate, @Nullable Predicate<E> breakPredicate)
public static <E> Collection<E> filter(@Nullable Object anyObject, @Nullable Predicate2<Integer,E> consumePredicate, @Nullable Predicate2<Integer,E> breakPredicate)
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,M extends Map<K,V>> M map(@Nullable Object anyObject, @NonNull Mapper<E,Pair<K,V>> mapper)
public static <K,V,R,M extends Map<K,V>> List<R> map(@Nullable M map, @NonNull Function2<K,V,R> mapper)
public static <K,V,K1,V1,M extends Map<K,V>> Map<K1,V1> map(@Nullable M map, @NonNull Mapper2<K,V,Pair<K1,V1>> mapper)
public static <E> Collection<E> flat(Collection<Collection<E>> collections)
public static <E,R> Collection<R> flatMap(@NonNull Function<E,R> mapper, @Nullable Collection<E[]> collection)
public static <E,R,C extends Collection<? extends Iterable<E>>> Collection<R> flatMap(@Nullable C collection, @NonNull Function<E,R> mapper)
public static <E,C extends Iterable<E>> void forEach(@Nullable C collection, @NonNull Consumer<E> consumer)
public static <E,C extends Iterable<E>> void forEach(@Nullable C collection, @Nullable Predicate<E> consumePredicate, @NonNull Consumer<E> consumer)
public static <E,C extends Iterable<E>> void forEach(@Nullable C collection, @NonNull Consumer<E> consumer, @Nullable Predicate<E> breakPredicate)
public static <E,C extends Iterable<E>> void forEach(@Nullable C collection, @Nullable Predicate<E> consumePredicate, @NonNull Consumer<E> consumer, @Nullable Predicate<E> breakPredicate)
public static <E,C extends Collection<E>> void forEach(@Nullable C collection, @NonNull Consumer2<Integer,E> consumer)
public static <E,C extends Iterable<E>> void forEach(@Nullable C collection, @NonNull Consumer2<Integer,E> consumer)
public static <E,C extends Iterable<E>> void forEach(@Nullable C collection, @NonNull Consumer2<Integer,E> consumer, @Nullable Predicate2<Integer,E> breakPredicate)
public static <E,C extends Iterable<E>> void forEach(@Nullable C collection, @Nullable Predicate2<Integer,E> consumePredicate, @NonNull Consumer2<Integer,E> consumer)
public static <E,C extends Iterable<E>> void forEach(@Nullable C collection, @Nullable Predicate2<Integer,E> consumePredicate, @NonNull Consumer2<Integer,E> consumer, @Nullable Predicate2<Integer,E> breakPredicate)
public static <E> void forEach(@Nullable E[] array, @NonNull Consumer2<Integer,E> consumer)
public static <E> void forEach(@Nullable E[] array, @NonNull Consumer2<Integer,E> consumer, @Nullable Predicate2<Integer,E> breakPredicate)
public static <E> void forEach(@Nullable E[] array, @Nullable Predicate2<Integer,E> consumePredicate, @NonNull Consumer2<Integer,E> consumer)
public static <E> void forEach(@Nullable E[] array, @Nullable Predicate<E> consumePredicate, @NonNull Consumer<E> consumer, @Nullable Predicate<E> breakPredicate)
public static <E> void forEach(@Nullable E[] array, @Nullable Predicate2<Integer,E> consumePredicate, @NonNull Consumer2<Integer,E> consumer, @Nullable Predicate2<Integer,E> breakPredicate)
public static <K,V,M extends Map<? extends K,? extends V>> void forEach(@Nullable M map, @NonNull Consumer2<K,V> consumer)
public static <K,V,M extends Map<? extends K,? extends V>> void forEach(@Nullable M map, @NonNull Consumer2<K,V> consumer, @Nullable Predicate2<K,V> breakPredicate)
public static <K,V,M extends Map<? extends K,? extends V>> void forEach(@Nullable M map, @Nullable Predicate2<K,V> consumePredicate, @NonNull Consumer2<K,V> consumer)
public static <K,V,M extends Map<? extends K,? extends V>> void forEach(@Nullable M map, @Nullable Predicate2<K,V> consumePredicate, @NonNull Consumer2<K,V> consumer, @Nullable Predicate2<K,V> breakPredicate)
public static <E,C extends Collection<E>> Integer firstOccurrence(C c, E item)
public static <E,C extends Collection<E>> int firstOccurrence(C c, Predicate2<Integer,E> predicate)
public static <E,C extends Iterable<E>,O> O firstMap(@Nullable C collection, @NonNull Function2<Integer,E,O> mapper)
public static <E,C extends Iterable<E>,O> O firstMap(@Nullable C collection, @NonNull Function2<Integer,E,O> mapper, Predicate<O> breakPredicate)
public static <E,C extends Iterable<E>,O> O firstMap(@Nullable C collection, @NonNull Function2<Integer,E,O> mapper, Predicate2<E,O> breakPredicate)
public static <K,V,O> O firstMap(@Nullable Map<K,V> map, @NonNull Function2<K,V,O> mapper)
public static <K,V,O> O firstMap(@Nullable Map<K,V> map, @NonNull Function2<K,V,O> mapper, Predicate<O> breakPredicate)
public static <E,C extends Collection<E>> E findFirst(@Nullable C collection)
public static <E,C extends Collection<E>> E findFirst(@Nullable C 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,C extends Collection<E>> List<E> findN(@Nullable C collection, @Nullable Predicate<E> predicate, int n)
public static <E,C extends Collection<E>> List<Pair<Integer,E>> findNPairs(@Nullable C collection, @Nullable Predicate2<Integer,E> predicate, int n)
public static <K,V> Map<? extends K,? extends V> findN(@Nullable Map<? extends K,? extends V> map, @Nullable Predicate2<K,V> predicate, int n)
public static <E,C extends Collection<E>> boolean removeIf(@Nullable C 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,C extends Collection<E>> boolean anyMatch(@Nullable C collection, @NonNull Predicate<E> predicate)
public static <K,V,M extends Map<? extends K,? extends V>> boolean anyMatch(@Nullable M map, @NonNull Predicate2<K,V> predicate)
public static boolean allMatch(@NonNull Predicate predicate, @Nullable Object... collection)
public static <E,C extends Collection<E>> boolean allMatch(@Nullable C collection, @NonNull Predicate<E> predicate)
public static <K,V,M extends Map<? extends K,? extends V>> boolean allMatch(@Nullable M map, @NonNull Predicate2<K,V> predicate)
public static boolean noneMatch(@NonNull Predicate predicate, @Nullable Object... collection)
public static <E,C extends Collection<E>> boolean noneMatch(@Nullable C collection, @NonNull Predicate<E> predicate)
public static <K,V,M extends Map<? extends K,? extends V>> boolean noneMatch(@Nullable M map, @NonNull Predicate2<K,V> predicate)
public static <E,C extends Collection<E>> Set<E> distinct(@Nullable C collection)
public static <E> E[] limit(E[] array,
int maxSize)
public static <E,C extends Collection<E>> List<E> limit(@Nullable C collection, int maxSize)
public static <E> E[] skip(@Nullable E[] array, int n)
public static <E,C extends Collection<E>> List<E> skip(@Nullable C collection, int n)
public static <E,K> List<List<E>> partitionBy(Iterator<E> c, Function2<Integer,E,K> classifier)
public static <E,K> List<List<E>> partitionBy(Iterable<E> c, Function2<Integer,E,K> classifier)
public static <E> List<List<E>> partitionByCount(Iterable<E> c, int partitionCount)
public static <E> List<List<E>> partitionBySize(Iterable<E> c, int partitionSize)
E - c - partitionSize - public static <E extends Comparable<E>,C extends Collection<E>> TreeSet<E> sort(@Nullable C collection, boolean reverse)
public static <E,C extends Collection<E>> TreeSet<E> sort(@Nullable C collection, @NonNull Comparator<E> comparator)
public static <E,C extends Collection<E>> TreeSet<E> sort(@Nullable C collection, @NonNull Comparator<E> comparator, boolean reverse)
public static <K,V,M extends Map<K,V>> M sort(@Nullable M map, @NonNull Comparator<K> comparator)
public static <E> List<E> reverse(@Nullable List<E> list, boolean newOne)
public static <E,C extends Collection<E>> int count(@Nullable C 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 <X,Y,E,C extends Collection<E>> CollectionDiffResult<E> diff(@Nullable X oldObject, @NonNull Function<X,E> oldMapper, @Nullable Y newObject, @NonNull Function<Y,E> newMapper)
public static <X,Y,E,C extends Collection<E>> CollectionDiffResult<E> diff(@Nullable X oldObject, @NonNull Function<X,E> oldMapper, @Nullable Y newObject, @NonNull Function<Y,E> newMapper, @Nullable Comparator<E> elementComparator)
public static <X,Y,E,C extends Collection<E>> CollectionDiffResult<E> diff(@Nullable X oldObject, @NonNull Function<X,E> oldMapper, @Nullable Y newObject, @NonNull Function<Y,E> newMapper, @Nullable Comparator<E> elementComparator, @Nullable KeyBuilder<String,E> keyBuilder)
public static <E,C extends Collection<E>> CollectionDiffResult<E> diff(@Nullable C oldCollection, @Nullable C newCollection)
public static <E,C extends Collection<E>> CollectionDiffResult<E> diff(@Nullable C oldCollection, @Nullable C newCollection, @Nullable Comparator<E> elementComparator)
public static <E,C extends Collection<E>> CollectionDiffResult<E> diff(@Nullable C oldCollection, @Nullable C newCollection, @Nullable Comparator<E> elementComparator, @Nullable KeyBuilder<String,E> keyBuilder)
public static <K,V,M extends Map<K,V>> MapDiffResult<K,V> diff(@Nullable M oldMap, @Nullable M newMap)
public static <K,V,M extends Map<K,V>> MapDiffResult<K,V> diff(@Nullable M oldMap, @Nullable M newMap, @Nullable Comparator<V> valueComparator)
public static <K,V,M extends Map<K,V>> MapDiffResult<K,V> diff(@Nullable M oldMap, @Nullable M 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,C extends Collection<E>> void addAll(@NonNull C dest, @Nullable Iterable<E> iterable)
public static <E,C extends Collection<E>> void addAll(@NonNull C dest, @Nullable E... iterator)
public static <E,C extends Collection<E>> void addAll(@NonNull C dest, @Nullable Iterator<E> iterator)
public static <E,C extends Collection<E>> void addTo(@NonNull C srcCollection, @Nullable C targetCollection)
public static <E1,C1 extends Collection<E1>,E2,C2 extends Collection<E2>> void addTo(C1 srcCollection, C2 targetCollection, Function<E1,E2> mapper)
public static <E,C extends Collection<E>> C concat(@Nullable C c1, @Nullable C c2)
public static <E,C extends Collection<E>> C concat(@Nullable C c1, @Nullable C c2, boolean newOne)
public static <K,V> Map<K,V> copy(Map<K,V> source)
K - the map key typeV - the map value typesource - the Map to clonepublic static <E,C extends Collection<E>> C merge(@Nullable C c1, @Nullable C c2)
public static <E,C extends Collection<E>> C merge(@Nullable C c1, @Nullable C c2, boolean newOne)
public static <K,V,M extends Map<K,V>> M merge(@Nullable M map1, @Nullable M map2, boolean newOne)
public static <E,C1 extends Collection<E>,C2 extends Collection<E>> boolean containsAny(C1 c1, C2 c2)
public static <E> boolean contains(E[] collection,
E obj)
public static <E> boolean contains(Collection<E> collection, E obj)
public static <E> boolean contains(E[] collection,
@Nullable
E obj,
@Nullable
Predicate<E> predicate)
public static <E> boolean contains(Collection<E> collection, @Nullable E obj, @Nullable Predicate<E> predicate)
public static <E,C1 extends Collection<E>,C2 extends Collection<E>> boolean containsAll(C1 c1, C2 c2)
public static <E,C1 extends Collection<E>,C2 extends Collection<E>> boolean containsNone(C1 c1, C2 c2)
public static <E,C1 extends Collection<E>,C2 extends Collection<E>> Set<E> intersection(C1 c1, C2 c2)
public static <E,C1 extends Collection<E>,C2 extends Collection<E>> Set<E> union(C1 c1, C2 c2)
public static <E,C extends Iterable<E>> E reduce(@Nullable Iterable<E> iterable, Operator2<E> operator)
public static <K,E> Map<K,List<E>> groupBy(@Nullable E[] iterable, @NonNull Function<E,K> classifier)
public static <K,E> Map<K,List<E>> groupBy(@Nullable E[] iterable, @NonNull Function<E,K> classifier, @Nullable Supplier0<Map<K,List<E>>> mapFactory)
public static <K,E,C extends Collection<E>> Map<K,List<E>> groupBy(@Nullable C iterable, @NonNull Function<E,K> classifier)
public static <K,E,C extends Collection<E>> Map<K,List<E>> groupBy(@Nullable Iterable<E> iterable, @NonNull Function<E,K> classifier, @Nullable Supplier0<Map<K,List<E>>> mapFactory)
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,K,V> Collector<E,Map<K,V>> toMap(@NonNull Supplier0<Map<K,V>> mapFactory, @NonNull Function<E,K> keyMapper, @NonNull Function<E,V> valueMapper)
public static <E,K> Collector<E,Map<K,List<E>>> groupingBy(@NonNull Function<E,K> classifier, @NonNull Supplier0<Map<K,List<E>>> mapFactory)
public static <E,K> Collector<E,Map<K,List<E>>> groupingBy(@NonNull Function2<Integer,E,K> classifier, @NonNull Supplier0<Map<K,List<E>>> mapFactory)
public static <E,K> Collector<E,Map<K,List<E>>> partitioningBy(@NonNull Function<E,K> classifier)
public static <E,K> Collector<E,Map<K,List<E>>> partitioningBy(@NonNull Function2<Integer,E,K> classifier)
public static <E,C extends Collection<E>> C clearNulls(@Nullable C collection)
public static <E> void shuffle(@NonNull List<E> list)
The hedge "approximately" is used in the foregoing description because default source of randomness is only approximately an unbiased source of independently chosen bits. If it were a perfect source of randomly chosen bits, then the algorithm would choose permutations with perfect uniformity.
This implementation traverses the list backwards, from the last element up to the second, repeatedly swapping a randomly selected element into the "current position". Elements are randomly selected from the portion of the list that runs from the first element to the current position, inclusive.
This method runs in linear time. If the specified list does not
implement the RandomAccess interface and is large, this
implementation dumps the specified list into an array before shuffling
it, and dumps the shuffled array back into the list. This avoids the
quadratic behavior that would result from shuffling a "sequential
access" list in place.
list - the list to be shuffled.UnsupportedOperationException - if the specified list or
its list-iterator does not support the set operation.public static <E> void shuffle(@NonNull List<E> list, @NonNull Random rnd)
This implementation traverses the list backwards, from the last element up to the second, repeatedly swapping a randomly selected element into the "current position". Elements are randomly selected from the portion of the list that runs from the first element to the current position, inclusive.
This method runs in linear time. If the specified list does not
implement the RandomAccess interface and is large, this
implementation dumps the specified list into an array before shuffling
it, and dumps the shuffled array back into the list. This avoids the
quadratic behavior that would result from shuffling a "sequential
access" list in place.
list - the list to be shuffled.rnd - the source of randomness to use to shuffle the list.UnsupportedOperationException - if the specified list or its
list-iterator does not support the set operation.public static <E> void swap(@NonNull List<E> list, int i, int j)
list - The list in which to swap elements.i - the index of one element to be swapped.j - the index of the other element to be swapped.IndexOutOfBoundsException - if either i or j
is out of range (i < 0 || i >= list.size()
|| j < 0 || j >= list.size()).public static <E> void swap(@NonNull E[] arr, int i, int j)
public static <E> int indexOf(List<E> list, E e)
public static <E> int indexOf(List<E> list, E e, int startIndex)
public static <E> int indexOf(List<E> list, E e, int startIndex, int endIndex)
E - list - e - startIndex - 包含endIndex - 不包含public static <E> int lastIndexOf(List<E> list, E e)
public static <E> int lastIndexOf(List<E> list, E e, int startIndex)
public static <E> int lastIndexOf(List<E> list, E e, int startIndex, int endIndex)
E - list - e - startIndex - endIndex - public static <E> int indexOf(E[] list,
E e)
public static <E> int indexOf(E[] list,
E e,
int startIndex)
public static <E> int indexOf(E[] list,
E e,
int startIndex,
int endIndex)
public static <E> int lastIndexOf(E[] list,
E e)
public static <E> int lastIndexOf(E[] list,
E e,
int startIndex)
public static <E> int lastIndexOf(E[] list,
E e,
int startIndex,
int endIndex)
public static <E> E apply(E input,
Function<E,E>... mappers)
Copyright © 2022. All rights reserved.