public class CollectionUtil extends Object
| Constructor and Description |
|---|
CollectionUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
arrayOf(T... items)
Create an array
|
static <T> boolean |
contains(T[] collection,
T target)
Check whether target exist in collection
|
static boolean |
containsAny(Collection<?> collectionLeft,
Collection<?> collectionRight)
Check two collection has any equaled item
|
static String |
join(Collection<?> collection,
String joinSymbol)
Join a collection into string
|
static <T> List<T> |
listOf(T... items)
Create a list
|
static <K,V> Map<K,V> |
mapOf(Pair<K,V>... pair)
Create a map
|
static <T> List<T> |
mutableListOf(T... items)
Generate a list of item
|
static <K,V> Map<K,V> |
orderMapOf(Pair<K,V>... pair)
Create an ordered map
|
static <T> Set<T> |
setOf(T... items)
Create a set
|
static Object[] |
slice(Object[] args,
int startPos)
Get slice of args[startPos, args.length]
|
static Object[] |
slice(Object[] args,
int startPos,
int endPos)
Get slice of args[startPos, endPos]
|
public static Object[] slice(Object[] args, int startPos)
args - original item arraystartPos - index of the first item to keeppublic static Object[] slice(Object[] args, int startPos, int endPos)
args - original item arraystartPos - index of the first item to keependPos - index of the last item to keeppublic static String join(Collection<?> collection, String joinSymbol)
collection - many items with proper toString() methodjoinSymbol - splitter of echo itemspublic static <T> boolean contains(T[] collection,
T target)
collection - many items to find fromtarget - an item to be foundpublic static boolean containsAny(Collection<?> collectionLeft, Collection<?> collectionRight)
collectionLeft - the first collectioncollectionRight - the second collectionpublic static <T> T[] arrayOf(T... items)
items - elements to addpublic static <T> List<T> listOf(T... items)
items - elements to addpublic static <T> List<T> mutableListOf(T... items)
items - elements to addpublic static <T> Set<T> setOf(T... items)
items - elements to addpublic static <K,V> Map<K,V> mapOf(Pair<K,V>... pair)
pair - elements to addCopyright © 2022. All rights reserved.