Package jetbrains.buildServer.util
Class CollectionsUtil
- java.lang.Object
-
- jetbrains.buildServer.util.CollectionsUtil
-
public class CollectionsUtil extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CollectionsUtil.EnumerationIteratorAdaptor<T>
static class
CollectionsUtil.FilteringEnumeration<T>
static class
CollectionsUtil.FilteringIterable<T>
static class
CollectionsUtil.FilteringIterator<T>
-
Field Summary
Fields Modifier and Type Field Description static Filter
ACCEPT_ALL
static Converter
SAME
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> Filter<T>
acceptAllFilter()
Type safe accept all filterstatic <T> boolean
addIfNotNull(Collection<T> collection, T object)
Adds an element to the collection unless the element is null.static <T,Q>
List<T>applyOrder(Q[] sortedIds, List<T> allElements, Map<Q,T> idToElementMap)
Accepts elements and reorders them according to provided partial order of the elements.static <T> Map<T,T>
asMap(T... args)
Creates map from a given even number of parametersstatic <T> String
asString(Collection<T> collection, int maxElems)
static <T> int
binarySearch(List<? extends T> list, Condition<? super T> condition)
Returns the index of the first element for which condition is true.
It is supposed for the list that some index K exists such as:
1.static <SourceType>
List<SourceType>collectUniqueObjectList(List<SourceType> list)
static <T> boolean
contains(Iterable<T> iterable, Filter<? super T> filter)
Checks whether giveniterable
has at least one element satisfying thefilter
static <Result,Source>
List<Result>convertAndFilterNulls(Iterable<Source> source, Converter<Result,Source> converter)
Converts the collection (or any iterable) excluding thenull
s afterwards.static <ResultType,SourceType>
List<ResultType>convertCollection(Iterable<? extends SourceType> source, Converter<ResultType,SourceType> converter)
Create collection of type ResultType from collection of elements of type SourceType.static <ResultType,SourceType>
List<ResultType>convertCollection(Collection<? extends SourceType> source, Converter<ResultType,SourceType> converter)
Create collection of type ResultType from collection of elements of type SourceType.static <K,V,K2,V2>
voidconvertMap(Map<? extends K,? extends V> source, Map<? super K2,? super V2> target, Converter<K2,K> keyConverter, Converter<V2,V> valueConverter)
Converts `Map<K, V>` into `Map<K2, V2>` coercing keys and values given respective convertersstatic <ResultType,SourceType>
Set<ResultType>convertSet(Iterable<? extends SourceType> source, Converter<ResultType,SourceType> converter)
Create set of type ResultType from collection of elements of type SourceType.static <ResultType,SourceType>
Set<ResultType>convertSet(Collection<? extends SourceType> source, Converter<ResultType,SourceType> converter)
Create set of type ResultType from collection of elements of type SourceType.static <T extends Enum<T>>
EnumSet<T>copyOf(Class<T> type, Collection<T> from)
static <T> void
copyWithPadding(Collection<T> source, T[] target, int targetStartIdx, T paddingValue)
Copies values from the source collection to the target array.static <T> void
copyWithPadding(Collection<T> source, T[] target, T paddingValue)
Copies values from the source collection to the target array.static <K,V>
intcount(Map<K,V> map, Filter<K> keyFilter, Filter<V> valueFilter)
counts a number of entries in map that matches given filters (by &&)static <K,V>
Map<K,V>emptyHashMapIfNull(Map<K,V> map)
static <T> List<T>
ensureModifiable(List<T> items)
static <ResultType,SourceType>
List<ResultType>filterAndConvertCollection(Iterable<? extends SourceType> source, Converter<ResultType,SourceType> converter, Filter<SourceType> filter)
Create collection of type ResultType from collection of elements of type SourceType.static <ResultType,ResultCollection extends Collection<ResultType>,SourceType>
ResultCollectionfilterAndConvertCollection(Iterable<? extends SourceType> sources, ResultCollection collection, Converter<ResultType,SourceType> converter, Filter<SourceType> filter)
static <ResultType,SourceType>
List<ResultType>filterAndConvertCollection(Collection<? extends SourceType> source, Converter<ResultType,SourceType> converter, Filter<SourceType> filter)
Create collection of type ResultType from collection of elements of type SourceType.static <SourceType>
List<SourceType>filterCollection(Iterable<? extends SourceType> source, Filter<SourceType> filter)
Elements are filtered basing on Filter interface.static <SourceType>
List<SourceType>filterCollection(Collection<? extends SourceType> source, Filter<SourceType> filter)
Elements are filtered basing on Filter interface.static <K,V>
Map<K,V>filterMap(Map<K,V> map, Filter<K> keyFilter, Filter<V> valueFilter)
Creates a copy of map filtering it by values filter, order is preservedstatic <K,V>
Map<K,V>filterMapByKeys(Map<K,V> map, Filter<K> filter)
Creates a copy of a map filtering it by keys filter, order is preservedstatic <K,V>
Map<K,V>filterMapByValues(Map<K,V> map, Filter<V> filter)
Creates a copy of map filtering it by values filter, order is preservedstatic <T> List<T>
filterNulls(Collection<T> collection)
Filters the collection, excluding allnull
s from it.static <T> T
findFirst(Iterable<T> iterable, Filter<? super T> filter)
Searches a collection and returns first element which fulfills given filter functionstatic <T> T
findFirst(Iterator<T> iterator, Filter<? super T> filter)
Traverses with the iterator and returns first element which fulfills given filter function.static <T> Set<T>
flatten(Collection<Pair<T,T>> data)
creates set of pair's first and secondsstatic <T> Set<T>
flatten(Map<T,T> data)
creates set of pair's first and secondsstatic <K,V>
Map<K,List<V>>groupBy(Collection<V> collection, Converter<K,V> converter)
Groups values in collection according to some computed attribute.static <T extends Comparable<T>>
voidinsertWithSorting(T o, List<T> list)
Insert an object into target collection into a position so collection remains sorted ascendingstatic <T> void
insertWithSorting(T o, List<T> list, Comparator<T> comp)
Insert an object into target collection into a position so collection remains sorted ascendingstatic <T> Set<T>
intersect(Collection<T> set1, Collection<T> set2)
Intersection: items present in both sets simultaneously.static <T> Collection<T>
join(Collection<T>... a)
Merges two collectionsstatic <T> Collection<T>
join(Collection<T> a, Collection<T> b)
Merges two collectionsstatic <T> Collection<T>
join(Collection<T> a, Collection<T> b, Collection<T> c)
Merges two collectionsstatic <T> Set<T>
minus(Collection<T> minuend, Collection<T> subtrahend)
Differs: items from the first collection excluding items from the second collection.static <T> SortedSet<T>
minus(SortedSet<T> minuend, Set<T> subtrahend)
Differs: items from the first (sorted) set excluding items from the second set.static <T> void
removeDuplicates(Collection<T> collection)
Removes the duplicates from the provided collection of elements.static <T> Collection<T>
removeDuplicatesPreservingOrder(Collection<T> collection)
The same asremoveDuplicates(java.util.Collection)
, but preserves the order of non duplicated elements.static <T,Coll extends Iterable<T>>
CollremoveNulls(Coll collection)
static void
retainMatched(Collection<String> stringCollection, Pattern pattern)
static <T> Iterable<T>
reversed(List<T> list)
Creates an iterable over a list looping in reverse direction.static <T> Set<T>
setOf(T... args)
Creates a set from given parametersstatic <T extends Comparable<? super T>>
booleansortedListsIntersect(List<T> list1, List<T> list2)
Accepts two sorted lists and returns true if they have at least one common element, or false otherwisestatic <T> List<List<T>>
split(List<T> toSplit, int numParts)
Split one collection into a collection of smaller collectionsstatic <T> Stream<T>
streamOf(Collection<T> collection)
Creates a stream of nullable collectionstatic String
to_s(Collection c)
Returns a debug-oriented representation of the collection, when all elements are joined with "\r\n"static <T> T[]
toArray(Collection<T> collection, Class<T> clazz)
Converts the given collection to an array.static <T> ArrayList<T>
toArrayList(Collection<T> items)
static String[]
toStringArray(Collection<String> strings)
Converts the given collection of string to an array.static <T> Iterator<T>
toTypedIterator(Class<T> clazz, Iterator data)
Converts not-typed iterator to a typed iterator with lazy type checkstatic <T> Collection<T>
unite(Collection<? extends T>... col)
Deprecated.static <K,E>
Map<K,Set<E>>unmodifiable(Map<K,Set<E>> map)
-
-
-
Method Detail
-
acceptAllFilter
@NotNull public static <T> Filter<T> acceptAllFilter()
Type safe accept all filter- Type Parameters:
T
- type- Returns:
- filter accepting all values
- Since:
- 7.1
-
flatten
@NotNull public static <T> Set<T> flatten(@NotNull Collection<Pair<T,T>> data)
creates set of pair's first and seconds- Since:
- 8.1
-
flatten
@NotNull public static <T> Set<T> flatten(@NotNull Map<T,T> data)
creates set of pair's first and seconds- Since:
- 8.1
-
filterAndConvertCollection
public static <ResultType,SourceType> List<ResultType> filterAndConvertCollection(Collection<? extends SourceType> source, @NotNull Converter<ResultType,SourceType> converter, @NotNull Filter<SourceType> filter)
Create collection of type ResultType from collection of elements of type SourceType. Elements are filtered basing on Filter interface and conversion from SourceType to ResultType is performed using Converter interface.- Parameters:
source
- source collectionconverter
- converter from one element to anotherfilter
- filter which allows to skip some elements of the source collection- Returns:
- converted and filtered collection
-
filterAndConvertCollection
public static <ResultType,SourceType> List<ResultType> filterAndConvertCollection(Iterable<? extends SourceType> source, @NotNull Converter<ResultType,SourceType> converter, @NotNull Filter<SourceType> filter)
Create collection of type ResultType from collection of elements of type SourceType. Elements are filtered basing on Filter interface and conversion from SourceType to ResultType is performed using Converter interface.- Parameters:
source
- source collectionconverter
- converter from one element to anotherfilter
- filter which allows to skip some elements of the source collection- Returns:
- converted and filtered collection
-
filterAndConvertCollection
public static <ResultType,ResultCollection extends Collection<ResultType>,SourceType> ResultCollection filterAndConvertCollection(Iterable<? extends SourceType> sources, @NotNull ResultCollection collection, @NotNull Converter<ResultType,SourceType> converter, @NotNull Filter<SourceType> filter)
-
join
public static <T> Collection<T> join(Collection<T>... a)
Merges two collections- Type Parameters:
T
- type of collection elements- Parameters:
a
- collections to join- Returns:
- merged collection
- Since:
- 5.1
-
join
public static <T> Collection<T> join(@NotNull Collection<T> a, @NotNull Collection<T> b)
Merges two collections- Type Parameters:
T
- type of collection elements- Parameters:
a
- collectionb
- collection- Returns:
- merged collection
- Since:
- 5.1
-
join
public static <T> Collection<T> join(@NotNull Collection<T> a, @NotNull Collection<T> b, @NotNull Collection<T> c)
Merges two collections- Type Parameters:
T
- type of collection elements- Parameters:
a
- collectionb
- collectionc
- collection- Returns:
- merged collection
- Since:
- 5.1
-
filterCollection
public static <SourceType> List<SourceType> filterCollection(Collection<? extends SourceType> source, @NotNull Filter<SourceType> filter)
Elements are filtered basing on Filter interface.- Parameters:
source
- source collectionfilter
- filter which allows to skip some elements of the source collection- Returns:
- filtered collection
-
filterCollection
public static <SourceType> List<SourceType> filterCollection(Iterable<? extends SourceType> source, @NotNull Filter<SourceType> filter)
Elements are filtered basing on Filter interface.- Parameters:
source
- source collectionfilter
- filter which allows to skip some elements of the source collection- Returns:
- filtered collection
-
convertCollection
public static <ResultType,SourceType> List<ResultType> convertCollection(Collection<? extends SourceType> source, Converter<ResultType,SourceType> converter)
Create collection of type ResultType from collection of elements of type SourceType. Elements conversion from SourceType to ResultType is performed using Converter interface.- Parameters:
source
- source collectionconverter
- converter from one element to another- Returns:
- converted and filtered collection
-
convertCollection
public static <ResultType,SourceType> List<ResultType> convertCollection(Iterable<? extends SourceType> source, Converter<ResultType,SourceType> converter)
Create collection of type ResultType from collection of elements of type SourceType. Elements conversion from SourceType to ResultType is performed using Converter interface.- Parameters:
source
- source collectionconverter
- converter from one element to another- Returns:
- converted and filtered collection
-
convertSet
public static <ResultType,SourceType> Set<ResultType> convertSet(Collection<? extends SourceType> source, Converter<ResultType,SourceType> converter)
Create set of type ResultType from collection of elements of type SourceType. Elements conversion from SourceType to ResultType is performed using Converter interface.- Parameters:
source
- source collectionconverter
- converter from one element to another- Returns:
- converted and filtered collection
-
convertSet
public static <ResultType,SourceType> Set<ResultType> convertSet(Iterable<? extends SourceType> source, Converter<ResultType,SourceType> converter)
Create set of type ResultType from collection of elements of type SourceType. Elements conversion from SourceType to ResultType is performed using Converter interface.- Parameters:
source
- source collectionconverter
- converter from one element to another- Returns:
- converted and filtered collection
-
collectUniqueObjectList
public static <SourceType> List<SourceType> collectUniqueObjectList(List<SourceType> list)
-
findFirst
@Nullable public static <T> T findFirst(Iterable<T> iterable, Filter<? super T> filter)
Searches a collection and returns first element which fulfills given filter function- Parameters:
iterable
- collection of elementsfilter
- filter to satisfy- Returns:
- first element for which filter function returns true or null if no such element exists
- Since:
- 7.0
-
findFirst
@Nullable public static <T> T findFirst(@NotNull Iterator<T> iterator, @NotNull Filter<? super T> filter)
Traverses with the iterator and returns first element which fulfills given filter function. The iterator state will be changed after this method use!- Parameters:
iterator
- iteratorfilter
- filter to satisfy- Returns:
- first element for which filter function returns true or null if no such element exists
- Since:
- 2021.2
-
contains
public static <T> boolean contains(Iterable<T> iterable, Filter<? super T> filter)
Checks whether giveniterable
has at least one element satisfying thefilter
- Parameters:
iterable
- collection to check- Returns:
- true if iterable has elements satisfying the filter, else otherwise
- Since:
- 8.1
-
insertWithSorting
public static <T extends Comparable<T>> void insertWithSorting(@NotNull T o, @NotNull List<T> list)
Insert an object into target collection into a position so collection remains sorted ascending- Parameters:
o
- object to insertlist
- list of objects which should be sorted. All items should be added to the list using this function
-
insertWithSorting
public static <T> void insertWithSorting(@NotNull T o, @NotNull List<T> list, @NotNull Comparator<T> comp)
Insert an object into target collection into a position so collection remains sorted ascending- Parameters:
o
- object to insertlist
- list of objects which should be sorted. All items should be added to the list using this function and using same comparatorcomp
- comparator for the objects in the list
-
to_s
@NotNull public static String to_s(@NotNull Collection c)
Returns a debug-oriented representation of the collection, when all elements are joined with "\r\n"- Parameters:
c
- collection to process- Returns:
- see above
-
split
@NotNull public static <T> List<List<T>> split(@NotNull List<T> toSplit, int numParts)
Split one collection into a collection of smaller collections- Type Parameters:
T
- collection items' base type- Parameters:
toSplit
- collection to splitnumParts
- number of parts to have- Returns:
- collection of small collections
-
retainMatched
public static void retainMatched(@Nullable Collection<String> stringCollection, @NotNull Pattern pattern)
-
minus
@NotNull public static <T> Set<T> minus(Collection<T> minuend, @NotNull Collection<T> subtrahend)
Differs: items from the first collection excluding items from the second collection.
-
minus
@NotNull public static <T> SortedSet<T> minus(@NotNull SortedSet<T> minuend, @NotNull Set<T> subtrahend)
Differs: items from the first (sorted) set excluding items from the second set.- Type Parameters:
T
- item type.- Parameters:
minuend
- first set.subtrahend
- second set.- Returns:
- the remainder of differs; with the comparator from minuend.
- Since:
- 8.0
-
intersect
@NotNull public static <T> Set<T> intersect(@Nullable Collection<T> set1, @Nullable Collection<T> set2)
Intersection: items present in both sets simultaneously.- Type Parameters:
T
- item type.- Parameters:
set1
- first set.set2
- second set.- Returns:
- the intersection of both sets.
-
sortedListsIntersect
public static <T extends Comparable<? super T>> boolean sortedListsIntersect(@NotNull List<T> list1, @NotNull List<T> list2)
Accepts two sorted lists and returns true if they have at least one common element, or false otherwise- Parameters:
list1
- - first listlist2
- - second list- Returns:
- see above
- Since:
- 2018.1.2
-
removeNulls
@NotNull public static <T,Coll extends Iterable<T>> Coll removeNulls(@NotNull Coll collection)
-
filterNulls
@NotNull public static <T> List<T> filterNulls(@NotNull Collection<T> collection)
Filters the collection, excluding allnull
s from it.- Type Parameters:
T
- elements' type- Parameters:
collection
- the collection to filter- Returns:
- a filtered collection
- Since:
- 7.0
- See Also:
convertCollection(Iterable, Converter)
,convertAndFilterNulls(Iterable, Converter)
-
convertAndFilterNulls
@NotNull public static <Result,Source> List<Result> convertAndFilterNulls(@NotNull Iterable<Source> source, @NotNull Converter<Result,Source> converter)
Converts the collection (or any iterable) excluding thenull
s afterwards.- Type Parameters:
Result
- result typeSource
- source type- Parameters:
source
- the source iterableconverter
- the converter- Returns:
- a converter collection without
null
s - Since:
- 7.1
- See Also:
convertCollection(Iterable, Converter)
-
unite
@NotNull @Deprecated public static <T> Collection<T> unite(@NotNull Collection<? extends T>... col)
Deprecated.- Parameters:
col
- collection(s)- Returns:
- Returns a new collection containing all the elements from the given collections
- Since:
- 7.0
-
applyOrder
public static <T,Q> List<T> applyOrder(@NotNull Q[] sortedIds, @NotNull List<T> allElements, @NotNull Map<Q,T> idToElementMap)
Accepts elements and reorders them according to provided partial order of the elements. Elements must be identifiable by string id. New order of elements is defined as the sorted array of identifiers. Note that array of identifiers size may not be the same as the size of the whole collection.- Parameters:
sortedIds
- new order of identifiersallElements
- elements to sortidToElementMap
- map from element id to element- Returns:
- reordered elements
-
asMap
@NotNull public static <T> Map<T,T> asMap(@NotNull T... args)
Creates map from a given even number of parameters- Type Parameters:
T
- type of parameters- Parameters:
args
- parameters as sequence of key, value- Returns:
- map
- Since:
- 7.0
-
setOf
@NotNull public static <T> Set<T> setOf(@NotNull T... args)
Creates a set from given parameters- Type Parameters:
T
- type of element- Parameters:
args
- elements of set- Returns:
- set
- Since:
- 7.0
-
removeDuplicates
public static <T> void removeDuplicates(@NotNull Collection<T> collection)
Removes the duplicates from the provided collection of elements. Notes:- If the
collection
is ordered (e.g.java.util.List
), the result order is not preserved. - The elements are required to support
hashCode
andequals
methods.
- Type Parameters:
T
- any type able to store inHashSet
- Parameters:
collection
- the collection to remove duplicates from
- If the
-
removeDuplicatesPreservingOrder
@NotNull public static <T> Collection<T> removeDuplicatesPreservingOrder(@NotNull Collection<T> collection)
The same asremoveDuplicates(java.util.Collection)
, but preserves the order of non duplicated elements. In some cases may return the samecollection
instance (but without duplicates).- Type Parameters:
T
- any type able to store inHashSet
- Parameters:
collection
- the collection to remove duplicates from- Returns:
- a filtered collection
- Since:
- 8.0
-
binarySearch
public static <T> int binarySearch(@NotNull List<? extends T> list, @NotNull Condition<? super T> condition)
Returns the index of the first element for which condition is true.
It is supposed for the list that some index K exists such as:
1. 0 <= K <= list size
2. condition is false for all indexes those are less than K
3. condition is true for all indexes those are equal or greater than K- Returns:
- K
- Since:
- 6.5.2
-
toTypedIterator
@NotNull public static <T> Iterator<T> toTypedIterator(@NotNull Class<T> clazz, @NotNull Iterator data)
Converts not-typed iterator to a typed iterator with lazy type check- Type Parameters:
T
- type of elements- Parameters:
clazz
- class of itemsdata
- not-typed iterator- Returns:
- lazy wrapper for a given iterator of given type
- Since:
- 7.0
-
filterMapByKeys
@NotNull public static <K,V> Map<K,V> filterMapByKeys(@NotNull Map<K,V> map, @NotNull Filter<K> filter)
Creates a copy of a map filtering it by keys filter, order is preserved- Type Parameters:
K
- typeV
- type- Parameters:
map
- mapfilter
- keys filter- Returns:
- copy of map with subset of values
- Since:
- 7.1
-
filterMapByValues
@NotNull public static <K,V> Map<K,V> filterMapByValues(@NotNull Map<K,V> map, @NotNull Filter<V> filter)
Creates a copy of map filtering it by values filter, order is preserved- Type Parameters:
K
- typeV
- type- Parameters:
map
- mapfilter
- values filter- Returns:
- copy of map with subset of values
- Since:
- 7.1
-
filterMap
@NotNull public static <K,V> Map<K,V> filterMap(@NotNull Map<K,V> map, @NotNull Filter<K> keyFilter, @NotNull Filter<V> valueFilter)
Creates a copy of map filtering it by values filter, order is preserved- Type Parameters:
K
- typeV
- type- Parameters:
map
- mapkeyFilter
- keys filtervalueFilter
- values filter- Returns:
- copy of map with subset of values
- Since:
- 7.1
-
count
public static <K,V> int count(@NotNull Map<K,V> map, @NotNull Filter<K> keyFilter, @NotNull Filter<V> valueFilter)
counts a number of entries in map that matches given filters (by &&)- Type Parameters:
K
- typeV
- type- Parameters:
map
- mapkeyFilter
- keys filtervalueFilter
- values filter- Returns:
- number of (key,value) pairs matching both filters
- Since:
- 7.1
-
groupBy
@NotNull public static <K,V> Map<K,List<V>> groupBy(@NotNull Collection<V> collection, @NotNull Converter<K,V> converter)
Groups values in collection according to some computed attribute. Note: 'null' elements from collection will be stored in group with 'null' key- Type Parameters:
K
- grouping attributeV
- value to group- Parameters:
collection
- collection to groupconverter
- converter which computes attribute to group by- Returns:
- map where key is grouping attribute and value is list of values corresponding to this attribute
- Since:
- 8.0
-
convertMap
public static <K,V,K2,V2> void convertMap(@NotNull Map<? extends K,? extends V> source, @NotNull Map<? super K2,? super V2> target, @NotNull Converter<K2,K> keyConverter, @NotNull Converter<V2,V> valueConverter)
Converts `Map<K, V>` into `Map<K2, V2>` coercing keys and values given respective converters- Parameters:
source
- source-maptarget
- target-mapkeyConverter
- keys convertervalueConverter
- values converter
-
toArray
public static <T> T[] toArray(@NotNull Collection<T> collection, @NotNull Class<T> clazz)
Converts the given collection to an array.- Type Parameters:
T
- items class.- Parameters:
collection
- the collection to convert.clazz
- items class.- Returns:
- the created array.
- Since:
- 9.0
-
toStringArray
public static String[] toStringArray(@NotNull Collection<String> strings)
Converts the given collection of string to an array.- Parameters:
strings
- the collection to convert.- Returns:
- created array of string.
- Since:
- 9.0
-
toArrayList
@NotNull public static <T> ArrayList<T> toArrayList(@NotNull Collection<T> items)
-
addIfNotNull
public static <T> boolean addIfNotNull(@NotNull Collection<T> collection, @Nullable T object)
Adds an element to the collection unless the element is null.
-
reversed
@NotNull public static <T> Iterable<T> reversed(@NotNull List<T> list)
Creates an iterable over a list looping in reverse direction. Useful in foreach constructions.- Parameters:
list
- - list to be processed- Returns:
- an iterable over a list looping in reverse direction. Useful in foreach constructions
-
streamOf
@NotNull public static <T> Stream<T> streamOf(@Nullable Collection<T> collection)
Creates a stream of nullable collection- Parameters:
collection
- nullable collection- Returns:
- empty stream if collection is null,
collection.stream()
otherwise
-
asString
@NotNull public static <T> String asString(@NotNull Collection<T> collection, int maxElems)
-
copyOf
public static <T extends Enum<T>> EnumSet<T> copyOf(@NotNull Class<T> type, @NotNull Collection<T> from)
-
unmodifiable
@NotNull public static <K,E> Map<K,Set<E>> unmodifiable(@NotNull Map<K,Set<E>> map)
-
copyWithPadding
public static <T> void copyWithPadding(@NotNull Collection<T> source, @NotNull T[] target, @NotNull T paddingValue)
Copies values from the source collection to the target array. If target array is bigger than the source then the rest of the array is filled with the padding value.- Type Parameters:
T
-- Parameters:
source
- source collectiontarget
- target arraypaddingValue
- padding value- Since:
- 2023.11
-
copyWithPadding
public static <T> void copyWithPadding(@NotNull Collection<T> source, @NotNull T[] target, int targetStartIdx, @NotNull T paddingValue)
Copies values from the source collection to the target array. If target array is bigger than the source then the rest of the array is filled with the padding value.- Type Parameters:
T
-- Parameters:
source
- source collectiontarget
- target arraypaddingValue
- padding value- Since:
- 2024.07
-
-