public class Collects extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static Object[] |
EMPTY_OBJECT_ARRAY |
| 构造器和说明 |
|---|
Collects() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> ArrayList<T> |
asArrayList(T... array) |
static <T> void |
batchProcess(List<T> list,
Consumer<List<T>> processor,
int batchSize) |
static <T> List<T> |
concat(List<T> list,
T... array) |
static <K,V> Map<K,V> |
concat(Map<K,V>... maps) |
static <T> T[] |
concat(T[] a1,
T... a2) |
static <S,T> List<T> |
convert(Collection<S> source,
Function<S,T> mapper) |
static <K1,K2,V> Map<K2,V> |
convert(Map<K1,V> source,
Function<K1,K2> keyMapper) |
static <K1,V1,K2,V2> |
convert(Map<K1,V1> source,
Function<K1,K2> keyMapper,
Function<V1,V2> valueMapper) |
static <S,T> Set<T> |
convert(Set<S> source,
Function<S,T> mapper) |
static <T> List<T> |
drainAll(BlockingQueue<T> queue) |
static <T> List<T> |
duplicate(List<T> list) |
static <T,R> List<R> |
duplicate(List<T> list,
Function<T,R> mapper)
Returns the duplicates elements for list
|
static <T> List<T> |
filter(List<T> list,
Predicate<T> predicate) |
static <T> T |
findAny(Collection<T> coll,
Predicate<T> predicate) |
static <R> List<R> |
generate(int size,
IntFunction<R> mapper) |
static <T> T |
get(List<T> list,
int index) |
static <T> T |
get(T[] array,
int index) |
static <T> T |
getFirst(Collection<T> coll)
Gets the first element from collection
|
static <T> T |
getLast(Collection<T> coll)
Gets the last element from collection
|
static <T> T |
getLast(T[] array) |
static <T> T[] |
newArray(Class<?> arrayType,
int length) |
static <E> ArrayDeque<E> |
newArrayDeque(E element) |
static <E> ArrayList<E> |
newArrayList(int initialCapacity,
E element) |
static <E> LinkedList<E> |
newLinkedList(E element) |
static List<int[]> |
partition(int[] array,
int size)
Returns consecutive sub array of an array,
each of the same size (the final list may be smaller).
|
static <E> List<E> |
sorted(List<E> list,
Comparator<? super E> comparator) |
static <R> List<R> |
split(String str,
Function<String,R> converter) |
static <R> List<R> |
split(String str,
String separator,
Function<String,R> converter) |
static <E,K> Map<K,E> |
toMap(Collection<E> list,
Function<E,K> keyMapper) |
static <E,K,V> Map<K,V> |
toMap(Collection<E> list,
Function<E,K> keyMapper,
Function<E,V> valueMapper) |
static Properties |
toProperties(Map<String,String> map) |
static <T> Set<T> |
truncate(Set<T> set,
int length) |
public static final Object[] EMPTY_OBJECT_ARRAY
public static <E> LinkedList<E> newLinkedList(E element)
public static <E> ArrayDeque<E> newArrayDeque(E element)
public static <E> ArrayList<E> newArrayList(int initialCapacity, E element)
public static <R> List<R> generate(int size, IntFunction<R> mapper)
public static <E,K> Map<K,E> toMap(Collection<E> list, Function<E,K> keyMapper)
public static <E,K,V> Map<K,V> toMap(Collection<E> list, Function<E,K> keyMapper, Function<E,V> valueMapper)
public static <K1,V1,K2,V2> Map<K2,V2> convert(Map<K1,V1> source, Function<K1,K2> keyMapper, Function<V1,V2> valueMapper)
public static Properties toProperties(Map<String,String> map)
public static <T,R> List<R> duplicate(List<T> list, Function<T,R> mapper)
list - the listpublic static <E> List<E> sorted(List<E> list, Comparator<? super E> comparator)
public static <T> T getLast(T[] array)
public static <T> T getFirst(Collection<T> coll)
T - the coll element typecoll - the collpublic static <T> T getLast(Collection<T> coll)
T - the coll element typecoll - the collpublic static <T> T get(T[] array,
int index)
public static <T> T get(List<T> list, int index)
public static <T> void batchProcess(List<T> list, Consumer<List<T>> processor, int batchSize)
public static List<int[]> partition(int[] array, int size)
Collects.partition(new int[]{1,1,2,5,3}, 1) -> [1, 1, 2, 5, 3]
Collects.partition(new int[]{1,1,2,5,3}, 3) -> [1, 1]; [2, 5]; [3]
Collects.partition(new int[]{1,1,2,5,3}, 5) -> [1]; [1]; [2]; [5]; [3]
Collects.partition(new int[]{1,1,2,5,3}, 6) -> [1]; [1]; [2]; [5]; [3]
Collects.partition(new int[]{1,1,2,5,3}, 100) -> [1]; [1]; [2]; [5]; [3]
array - the arraysize - the sizepublic static <T> T findAny(Collection<T> coll, Predicate<T> predicate)
public static <S,T> List<T> convert(Collection<S> source, Function<S,T> mapper)
@SafeVarargs public static <T> List<T> concat(List<T> list, T... array)
@SafeVarargs public static <T> T[] concat(T[] a1, T... a2)
@SafeVarargs public static <K,V> Map<K,V> concat(Map<K,V>... maps)
@SafeVarargs public static <T> ArrayList<T> asArrayList(T... array)
public static <T> List<T> drainAll(BlockingQueue<T> queue)
public static <T> T[] newArray(Class<?> arrayType, int length)
Copyright © 2025. All rights reserved.