@OpenApiAll
public class CollectionUtils
extends java.lang.Object
Constructor and Description |
---|
CollectionUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> java.util.Collection<T> |
append(java.util.Collection<T> source,
java.util.Collection<? extends T> v,
boolean allowDuplication)
Merges two vector
Result vector is source
|
static <T> java.util.Collection<T> |
append(java.util.Collection<T> source,
java.util.Iterator<? extends T> it,
boolean allowDuplication)
Merges two vector
Result vector is source
|
static <T> java.util.Collection<T> |
append(java.util.Collection<T> source,
java.util.Iterator<? extends T> it,
boolean allowDuplication,
boolean allowNulls)
Merges two vector
Result vector is source
|
static <T> java.util.Collection<T> |
append(java.util.Collection<T> source,
T[] array,
boolean allowDuplication)
Merges two vector
Result vector is source
|
static boolean |
contains(java.util.Iterator it,
java.lang.Object o)
Checks if given iterator contains given object.
|
static boolean |
containsAny(java.util.Collection location,
java.util.Collection what)
Returns true if location contains any element from what
|
static <S,T,C extends java.util.Collection<T>> |
convert(java.util.Collection<S> source,
C target,
Converter<? super S,? super T> converter)
Convert one (source) collection into another (target) collection.
|
static <C extends java.util.Collection<E>,E> |
createCollection(java.lang.Class<C> collection,
java.util.Iterator<E> it)
Creates given type collection and fills it with objects from given iterator
|
static <T> java.util.Collection<T> |
createFromStringRepresentation(java.lang.String string,
java.lang.String delimiter,
Converter<java.lang.String,T> converter)
Create collection from string.
|
static <T> java.lang.String |
createStringRepresentation(java.util.Collection<T> collection,
java.lang.String delimiter,
Converter<T,java.lang.String> converter)
Create string representation of given collection.
|
static <T> java.util.List<T> |
filterByClassType(java.util.Collection<?> input,
java.lang.Class<T> type)
Filters and casts collection from one type to another
|
static void |
leaveElements(java.util.List elements,
int numberToLeave)
Leaves a given number of first elements in the collection.
|
static java.lang.String |
mapToString(java.util.Map<java.lang.String,java.lang.String> map)
Serializes map to string.
|
static <T> java.util.Collection<T> |
notDublicatedList(java.util.Collection<T> collection)
Deprecated.
|
static <T> java.util.Collection<T> |
notDuplicatedList(java.util.Collection<T> collection)
Removes duplicates from given collection.
|
static java.util.Map<java.lang.String,java.lang.String> |
stringToMap(java.lang.String input)
Deserialize map from string.
|
public static <S,T,C extends java.util.Collection<T>> C convert(java.util.Collection<S> source, C target, Converter<? super S,? super T> converter)
S
- source collection element type.T
- target collection element type.C
- target collection type.source
- source collection.target
- target collection.converter
- converts each element.public static <T> java.util.Collection<T> append(java.util.Collection<T> source, java.util.Collection<? extends T> v, boolean allowDuplication)
source
- - vector to be appendedv
- - vector to be addedallowDuplication
- do not check for already added element if truepublic static <T> java.util.Collection<T> append(java.util.Collection<T> source, java.util.Iterator<? extends T> it, boolean allowDuplication)
source
- - vector to be appendedit
- - vector to be addedallowDuplication
- do not check for already added element if truepublic static <T> java.util.Collection<T> append(java.util.Collection<T> source, java.util.Iterator<? extends T> it, boolean allowDuplication, boolean allowNulls)
source
- - vector to be appendedit
- - vector to be addedallowDuplication
- do not check for already added element if trueallowNulls
- allows nullspublic static <T> java.util.Collection<T> append(java.util.Collection<T> source, T[] array, boolean allowDuplication)
source
- - vector to be appendedarray
- - vector to be addedallowDuplication
- do not check for already added element if truepublic static boolean contains(java.util.Iterator it, java.lang.Object o)
it
- the iterator.o
- the object.public static boolean containsAny(java.util.Collection location, java.util.Collection what)
location
- location collectionwhat
- what collection.@CheckForNull public static <C extends java.util.Collection<E>,E> C createCollection(java.lang.Class<C> collection, java.util.Iterator<E> it)
collection
- type collection.it
- The given iterator.public static <T> java.util.Collection<T> notDuplicatedList(java.util.Collection<T> collection)
collection
- collection to operate with. (makes sense when col are list (sets cant have identical elements).@Deprecated public static <T> java.util.Collection<T> notDublicatedList(java.util.Collection<T> collection)
notDuplicatedList(java.util.Collection)
collection
- collection to operate with. (makes sense when col are list (sets cant have identical elements).public static <T> java.lang.String createStringRepresentation(java.util.Collection<T> collection, java.lang.String delimiter, Converter<T,java.lang.String> converter)
collection
- collection.delimiter
- values delimiter.converter
- convert object to string.public static <T> java.util.Collection<T> createFromStringRepresentation(java.lang.String string, java.lang.String delimiter, Converter<java.lang.String,T> converter)
string
- string representation.delimiter
- values delimiter.converter
- convert string to object.public static void leaveElements(java.util.List elements, int numberToLeave)
elements
- elements to filter.numberToLeave
- number of elements to leave.@Nonnull public static java.lang.String mapToString(@Nonnull java.util.Map<java.lang.String,java.lang.String> map)
map
- map to serialize.@Nonnull public static java.util.Map<java.lang.String,java.lang.String> stringToMap(@Nonnull java.lang.String input)
input
- input string.public static <T> java.util.List<T> filterByClassType(java.util.Collection<?> input, java.lang.Class<T> type)
T
- typeinput
- input collectiontype
- desired output collection type