public final class CollectionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> Set<T> |
arrayToSet(T[] array)
Converts the specified array to a set.
|
static List<Integer> |
genIntegers(int start,
int end)
Generates a list of integers from the specified start(inclusion) to the
specified end(inclusion).
|
static List<Integer> |
getRandomIntegers(int start,
int end,
int size)
Gets a list of integers(size specified by the given size) between the
specified start(inclusion) and end(inclusion) randomly.
|
static <T> T[] |
jsonArrayToArray(JSONArray jsonArray,
Class<? extends T[]> newType)
Converts the specified
JSON array to an array. |
static <T> List<T> |
jsonArrayToList(JSONArray jsonArray)
Converts the specified
JSON array to a
list. |
static <T> Set<T> |
jsonArrayToSet(JSONArray jsonArray)
Converts the specified
JSON array to a
list. |
static <T> JSONArray |
listToJSONArray(List<T> list)
Converts the specified
list to a
JSON array. |
static <T> JSONArray |
toJSONArray(Collection<T> collection)
Converts the specified
collection to a JSON array. |
public static List<Integer> getRandomIntegers(int start, int end, int size)
start - the specified startend - the specified endsize - the given sizepublic static List<Integer> genIntegers(int start, int end)
start - the specified startend - the specified endpublic static <T> Set<T> arrayToSet(T[] array)
T - the type of elements maintained by the specified arrayarray - the specified arraypublic static <T> JSONArray listToJSONArray(List<T> list)
list to a
JSON array.T - the type of elements maintained by the specified listlist - the specified listJSON arraypublic static <T> JSONArray toJSONArray(Collection<T> collection)
collection to a JSON array.T - the type of elements maintained by the specified collectioncollection - the specified collectionJSON arraypublic static <T> Set<T> jsonArrayToSet(JSONArray jsonArray)
JSON array to a
list.T - the type of elements maintained by the specified json arrayjsonArray - the specified json arrayarray listpublic static <T> List<T> jsonArrayToList(JSONArray jsonArray)
JSON array to a
list.T - the type of elements maintained by the specified json arrayjsonArray - the specified json arrayarray listpublic static <T> T[] jsonArrayToArray(JSONArray jsonArray, Class<? extends T[]> newType)
JSON array to an array.T - the type of elements maintained by the specified json arrayjsonArray - the specified json arraynewType - the class of the copy to be returnedCopyright © 2009–2019 B3log. All rights reserved.