Package com.atlassian.jira.util.collect
Class CollectionUtil
java.lang.Object
com.atlassian.jira.util.collect.CollectionUtil
Deprecated.
since 10.0, use Java built-in utilities or specialised libraries
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> booleanDeprecated.Does the suppliedIterablecontain anything that matches the predicate?static <T> booleanDeprecated.Does the suppliedIteratorcontain anything that matches the predicate?static <T> List<T>copyAsImmutableList(Collection<? extends T> copy) Deprecated.Return an immutable list copy of the passed collection.static <K,V> Map<K, V> copyAsImmutableMap(Map<? extends K, ? extends V> copy) Deprecated.Return an immutable copy of the passed map.static <T> Set<T>copyAsImmutableSet(Collection<? extends T> copy) Deprecated.Return an immutable set copy of the passed collection.static <T> Iterable<T>Deprecated.Create a filteredIterable.static <T> Iterator<T>Deprecated.Create a filteredIterator.static <T,R extends T>
Collection<R>filterByType(Iterable<T> iterable, Class<R> subclass) Deprecated.Filter aCollectionfor the specified subtype.static <T> TfindFirstMatch(Iterable<? extends T> iterable, Predicate<T> predicate) Deprecated.Return the first found element that the predicate matches.static <T> TDeprecated.Get the first element of a anIterablein iteration order, or null if empty.static <T> voidDeprecated.For each element in the iterator, consume the contents.static <T> voidDeprecated.For each element in the iterator, consume the contents.static <T> intDeprecated.Returns the index of the first element that matches the predicate.static <K,R, S> Map<K, S> Deprecated.Take a map and eagerly transform all values into a new, immutable Map.static <T> List<T>sort(Collection<? extends T> collection, Comparator<T> comparator) Deprecated.Copy and sort the passed collection and return an unmodifiableListof the elements.static <T> List<T>Deprecated.Turn the iterable into a list.static <T> List<T>toList(Enumeration<? extends T> enumeration) Deprecated.Turn the enumeration into a list.static <T> List<T>Deprecated.Turn the iterator into a list.static <T> Set<T>Deprecated.Turn the iterable into a Set.static <T> Set<T>Deprecated.Turn the iterable into a Set.static <T,R> List<R> Deprecated.Return aListthat is transformed from elements of the input type to elements of the output type by a transformer function.static <T,R> List<R> Deprecated.Return a List that is transformed from elements of the input type to elements of the output type by a transformer function.static <T,R> Iterable<R> transformAndFilter(Iterable<T> iterable, Function<T, R> transformer, Predicate<R> predicate) Deprecated.static <T,R> Iterator<R> transformIterator(Iterator<? extends T> iterator, Function<T, R> transformer) Deprecated.Return anIteratorthat is transformed from elements of the input type to elements of the output type by a transformer function.static <T,R> Set<R> transformSet(Iterable<T> iterable, Function<T, R> transformer) Deprecated.Return aSetthat is transformed from elements of the input type to elements of the output type by a transformer function.
-
Constructor Details
-
CollectionUtil
public CollectionUtil()Deprecated.
-
-
Method Details
-
foreach
public static <T> void foreach(@Nonnull Iterator<? extends T> iterator, @Nonnull Consumer<T> consumer) Deprecated.For each element in the iterator, consume the contents.- Type Parameters:
T- the type of element to consume- Parameters:
iterator- to iterate over the elementsconsumer- to consume the elements
-
foreach
Deprecated.For each element in the iterator, consume the contents.- Type Parameters:
T- the element type- Parameters:
iterable- to iterate over the elements, may be nullconsumer- to consume the elements
-
toList
Deprecated.Turn the iterator into a list.- Type Parameters:
T- the element type- Parameters:
iterator- to iterate over the elements- Returns:
- an unmodifiable
Listof the elements in the iterator
-
toList
Deprecated.Turn the iterable into a list.- Type Parameters:
T- the element type- Parameters:
iterable- to iterate over the elements- Returns:
- an unmodifiable
Listof the elements in the iterator
-
toList
Deprecated.Turn the enumeration into a list.- Type Parameters:
T- the element type- Parameters:
enumeration- to enumerate over the elements- Returns:
- an unmodifiable
Listof the elements in the iterator
-
toSet
Deprecated.Turn the iterable into a Set.- Type Parameters:
T- the element type- Parameters:
iterable- to iterate over the elements- Returns:
- an unmodifiable
Setof the elements in the iterator
-
toSet
Deprecated.Turn the iterable into a Set.- Type Parameters:
T- the element type- Parameters:
iterator- to iterate over the elements- Returns:
- an unmodifiable
Setof the elements in the iterator
-
transform
public static <T,R> List<R> transform(@Nonnull Iterator<? extends T> iterator, @Nonnull Function<T, R> transformer) Deprecated.Return a List that is transformed from elements of the input type to elements of the output type by a transformer function.- Type Parameters:
T- the input typeR- the out type- Parameters:
iterator- to iterate over the contentstransformer- the function that performs the transformation- Returns:
- an unmodifiable List of the transformed type
-
transform
public static <T,R> List<R> transform(@Nonnull Iterable<? extends T> iterable, @Nonnull Function<T, R> transformer) Deprecated.Return aListthat is transformed from elements of the input type to elements of the output type by a transformer function.Note, this performs a copy and applies the transform to all elements. If you want a lazily applied function, see Transform
- Type Parameters:
T- the input typeR- the out type- Parameters:
iterable- the contentstransformer- the function that performs the transformation- Returns:
- an unmodifiable List of the transformed type
-
transformIterator
public static <T,R> Iterator<R> transformIterator(@Nonnull Iterator<? extends T> iterator, @Nonnull Function<T, R> transformer) Deprecated.Return anIteratorthat is transformed from elements of the input type to elements of the output type by a transformer function.- Type Parameters:
T- the input typeR- the out type- Parameters:
iterator- the contentstransformer- the function that performs the transformation- Returns:
- an
Iteratorof the transformed type
-
transformSet
public static <T,R> Set<R> transformSet(@Nonnull Iterable<T> iterable, @Nonnull Function<T, R> transformer) Deprecated.Return aSetthat is transformed from elements of the input type to elements of the output type by a transformer function.Note, this performs a copy and applies the transform to all elements.
- Type Parameters:
T- the input typeR- the output type- Parameters:
iterable- the contentstransformer- the function that performs the transformation- Returns:
- an unmodifiable Set of the transformed type
-
contains
public static <T> boolean contains(@Nonnull Iterator<? extends T> iterator, @Nonnull Predicate<T> predicate) Deprecated.Does the suppliedIteratorcontain anything that matches the predicate?- Type Parameters:
T- the element type- Parameters:
iterator- containing elementspredicate- the matcher- Returns:
- true if the predicate returns true for any elements.
-
contains
public static <T> boolean contains(@Nonnull Iterable<? extends T> iterable, @Nonnull Predicate<T> predicate) Deprecated.Does the suppliedIterablecontain anything that matches the predicate?- Type Parameters:
T- the element type- Parameters:
iterable- containing elementspredicate- the matcher- Returns:
- true if the predicate returns true for any elements.
-
filter
public static <T> Iterator<T> filter(@Nonnull Iterator<T> iterator, @Nonnull Predicate<? super T> predicate) Deprecated.Create a filteredIterator.- Type Parameters:
T- the element type- Parameters:
iterator- an iterator that only returns elements approved by the predicatepredicate- for checking the elements- Returns:
- a filtered
Iterator
-
filter
public static <T> Iterable<T> filter(@Nonnull Iterable<T> iterable, @Nonnull Predicate<? super T> predicate) Deprecated.Create a filteredIterable.- Type Parameters:
T- the element type- Parameters:
iterable- an iterable whose iterators only returns elements approved by the predicatepredicate- for checking the elements- Returns:
- a filtered
Iterable
-
transformAndFilter
public static <T,R> Iterable<R> transformAndFilter(Iterable<T> iterable, Function<T, R> transformer, Predicate<R> predicate) Deprecated. -
filterByType
public static <T,R extends T> Collection<R> filterByType(@Nonnull Iterable<T> iterable, @Nonnull Class<R> subclass) Deprecated.Filter aCollectionfor the specified subtype.- Type Parameters:
T- the incoming typeR- the result type- Parameters:
iterable- an iterable whose values are of the source typesubclass- the result type, only return elements if they are of this type- Returns:
- a filtered
Collectionof the subtype
-
sort
public static <T> List<T> sort(@Nonnull Collection<? extends T> collection, @Nonnull Comparator<T> comparator) Deprecated.Copy and sort the passed collection and return an unmodifiableListof the elements.- Type Parameters:
T- the element type- Parameters:
collection- the collection to copycomparator- for sorting- Returns:
- an unmodifiable
Listview of the elements.
-
copyAsImmutableList
Deprecated.Return an immutable list copy of the passed collection.- Type Parameters:
T- the type of elements for the returned collection.- Parameters:
copy- the collection to copy.- Returns:
- an immutable list copy of the passed collection.
-
copyAsImmutableSet
Deprecated.Return an immutable set copy of the passed collection.- Type Parameters:
T- the type of elements for the returned collection.- Parameters:
copy- the collection to copy.- Returns:
- an immutable set copy of the passed collection.
-
copyAsImmutableMap
Deprecated.Return an immutable copy of the passed map. The type of the reurned map is not gaurenteed to match the type of the passed map. If this is important, than do it yourself.- Type Parameters:
K- the type of key in the returned map.V- the type of value in the returned map.- Parameters:
copy- the map to copy.- Returns:
- the copied and immutable map.
-
findFirstMatch
Deprecated.Return the first found element that the predicate matches.- Type Parameters:
T- the type of element to return- Parameters:
iterable- that may contain the element to returnpredicate- to match the desired element- Returns:
- the first matched element or null if none found
-
indexOf
public static <T> int indexOf(@Nonnull Iterable<? extends T> iterable, @Nonnull Predicate<? super T> predicate) Deprecated.Returns the index of the first element that matches the predicate.- Type Parameters:
T- the type of the elements- Parameters:
iterable- collection of elementspredicate- to match the desired element- Returns:
- the 0-based index of the first element that matches the predicate or -1 if none found
-
first
Deprecated.Get the first element of a anIterablein iteration order, or null if empty.- Type Parameters:
T- the type- Parameters:
iterable- the thing to get something from.- Returns:
- the first thing the iterator spits out. May
-
map
Deprecated.Take a map and eagerly transform all values into a new, immutable Map.- Type Parameters:
K- the key typeR- the original value typeS- the new value type- Parameters:
map- the original mapmapper- the mapping function- Returns:
- a new immutable map
- See Also:
-