public final class CollectionUtil extends Object
Modifier and Type | Method and Description |
---|---|
static <K,V> List<V> |
addToValueList(Map<K,List<V>> map,
K key,
V value)
Adds a value to a list of values in the map.
|
static <T> T |
getItemAtPositionOrNull(Collection<T> collection,
int position)
Returns the n-th item or
null if collection is smaller. |
static boolean |
isEmpty(Collection collection)
Returns
true if the given collection is null or empty, otherwise returns false . |
static boolean |
isNotEmpty(Collection collection)
Returns
true if the given collection is not null and not empty, otherwise returns false . |
static <C> Collection<Data> |
objectToDataCollection(Collection<C> collection,
SerializationService serializationService)
Converts a collection of any type to a collection of
Data . |
static int[] |
toIntArray(Collection<Integer> collection)
Converts a
Collection to a primitive int[] array. |
static long[] |
toLongArray(Collection<Long> collection)
Converts a
Collection to a primitive long[] array. |
public static boolean isEmpty(Collection collection)
true
if the given collection is null
or empty, otherwise returns false
.collection
- the given collectiontrue
if collection is emptypublic static boolean isNotEmpty(Collection collection)
true
if the given collection is not null
and not empty, otherwise returns false
.collection
- the given collectiontrue
if collection is not emptypublic static <K,V> List<V> addToValueList(Map<K,List<V>> map, K key, V value)
map
- the given map of listskey
- the key of the target listvalue
- the value to add to the target listpublic static <T> T getItemAtPositionOrNull(Collection<T> collection, int position)
null
if collection is smaller.collection
- the given collectionposition
- position of the wanted itemnull
if the given collection is too smallNullPointerException
- if collection is null
public static <C> Collection<Data> objectToDataCollection(Collection<C> collection, SerializationService serializationService)
Data
.collection
- the given collectionserializationService
- will be used for converting object to Data
NullPointerException
- if collection is null
or contains a null
itempublic static int[] toIntArray(Collection<Integer> collection)
Collection
to a primitive int[]
array.collection
- the given collectionNullPointerException
- if collection is null
public static long[] toLongArray(Collection<Long> collection)
Collection
to a primitive long[]
array.collection
- the given collectionNullPointerException
- if collection is null
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.