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(List<S> source,
Function<S,T> mapper) |
static <S,T> Set<T> |
convert(Set<S> source,
Function<S,T> mapper) |
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 <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[] |
newArray(Class<? extends T[]> arrayType,
int length) |
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> Set<R> |
split(String str,
String separator,
Function<String,R> converter) |
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 <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 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)
@SafeVarargs public static <T> List<T> concat(List<T> list, T... array)
public static <T> T[] concat(T[] a1,
T... a2)
public static <T> ArrayList<T> asArrayList(T... array)
public static <T> T[] newArray(Class<? extends T[]> arrayType, int length)
Copyright © 2024. All rights reserved.