Class CollectionUtil

java.lang.Object
com.atlassian.jira.util.collect.CollectionUtil

@Deprecated public final class CollectionUtil extends Object
Deprecated.
since 10.0, use Java built-in utilities or specialised libraries
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> boolean
    contains(Iterable<? extends T> iterable, Predicate<T> predicate)
    Deprecated.
    Does the supplied Iterable contain anything that matches the predicate?
    static <T> boolean
    contains(Iterator<? extends T> iterator, Predicate<T> predicate)
    Deprecated.
    Does the supplied Iterator contain 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>
    filter(Iterable<T> iterable, Predicate<? super T> predicate)
    Deprecated.
    Create a filtered Iterable.
    static <T> Iterator<T>
    filter(Iterator<T> iterator, Predicate<? super T> predicate)
    Deprecated.
    Create a filtered Iterator.
    static <T, R extends T>
    Collection<R>
    filterByType(Iterable<T> iterable, Class<R> subclass)
    Deprecated.
    Filter a Collection for the specified subtype.
    static <T> T
    findFirstMatch(Iterable<? extends T> iterable, Predicate<T> predicate)
    Deprecated.
    Return the first found element that the predicate matches.
    static <T> T
    first(Iterable<? extends T> iterable)
    Deprecated.
    Get the first element of a an Iterable in iteration order, or null if empty.
    static <T> void
    foreach(Iterable<T> iterable, Consumer<T> consumer)
    Deprecated.
    For each element in the iterator, consume the contents.
    static <T> void
    foreach(Iterator<? extends T> iterator, Consumer<T> consumer)
    Deprecated.
    For each element in the iterator, consume the contents.
    static <T> int
    indexOf(Iterable<? extends T> iterable, Predicate<? super T> predicate)
    Deprecated.
    Returns the index of the first element that matches the predicate.
    static <K, R, S> Map<K,S>
    map(Map<K,R> map, Function<R,S> mapper)
    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 unmodifiable List of the elements.
    static <T> List<T>
    toList(Iterable<? extends T> iterable)
    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>
    toList(Iterator<? extends T> iterator)
    Deprecated.
    Turn the iterator into a list.
    static <T> Set<T>
    toSet(Iterable<? extends T> iterable)
    Deprecated.
    Turn the iterable into a Set.
    static <T> Set<T>
    toSet(Iterator<? extends T> iterator)
    Deprecated.
    Turn the iterable into a Set.
    static <T, R> List<R>
    transform(Iterable<? extends T> iterable, 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.
    static <T, R> List<R>
    transform(Iterator<? extends T> iterator, 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.
    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 an Iterator that 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 a Set that is transformed from elements of the input type to elements of the output type by a transformer function.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 elements
      consumer - to consume the elements
    • foreach

      public static <T> void foreach(Iterable<T> iterable, @Nonnull Consumer<T> consumer)
      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 null
      consumer - to consume the elements
    • toList

      public static <T> List<T> toList(@Nonnull Iterator<? extends T> iterator)
      Deprecated.
      Turn the iterator into a list.
      Type Parameters:
      T - the element type
      Parameters:
      iterator - to iterate over the elements
      Returns:
      an unmodifiable List of the elements in the iterator
    • toList

      public static <T> List<T> toList(@Nonnull Iterable<? extends T> iterable)
      Deprecated.
      Turn the iterable into a list.
      Type Parameters:
      T - the element type
      Parameters:
      iterable - to iterate over the elements
      Returns:
      an unmodifiable List of the elements in the iterator
    • toList

      public static <T> List<T> toList(@Nonnull Enumeration<? extends T> enumeration)
      Deprecated.
      Turn the enumeration into a list.
      Type Parameters:
      T - the element type
      Parameters:
      enumeration - to enumerate over the elements
      Returns:
      an unmodifiable List of the elements in the iterator
    • toSet

      public static <T> Set<T> toSet(@Nonnull Iterable<? extends T> iterable)
      Deprecated.
      Turn the iterable into a Set.
      Type Parameters:
      T - the element type
      Parameters:
      iterable - to iterate over the elements
      Returns:
      an unmodifiable Set of the elements in the iterator
    • toSet

      public static <T> Set<T> toSet(@Nonnull Iterator<? extends T> iterator)
      Deprecated.
      Turn the iterable into a Set.
      Type Parameters:
      T - the element type
      Parameters:
      iterator - to iterate over the elements
      Returns:
      an unmodifiable Set of 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 type
      R - the out type
      Parameters:
      iterator - to iterate over the contents
      transformer - 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 a List that 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 type
      R - the out type
      Parameters:
      iterable - the contents
      transformer - 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 an Iterator that is transformed from elements of the input type to elements of the output type by a transformer function.
      Type Parameters:
      T - the input type
      R - the out type
      Parameters:
      iterator - the contents
      transformer - the function that performs the transformation
      Returns:
      an Iterator of the transformed type
    • transformSet

      public static <T, R> Set<R> transformSet(@Nonnull Iterable<T> iterable, @Nonnull Function<T,R> transformer)
      Deprecated.
      Return a Set that 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 type
      R - the output type
      Parameters:
      iterable - the contents
      transformer - 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 supplied Iterator contain anything that matches the predicate?
      Type Parameters:
      T - the element type
      Parameters:
      iterator - containing elements
      predicate - 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 supplied Iterable contain anything that matches the predicate?
      Type Parameters:
      T - the element type
      Parameters:
      iterable - containing elements
      predicate - 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 filtered Iterator.
      Type Parameters:
      T - the element type
      Parameters:
      iterator - an iterator that only returns elements approved by the predicate
      predicate - 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 filtered Iterable.
      Type Parameters:
      T - the element type
      Parameters:
      iterable - an iterable whose iterators only returns elements approved by the predicate
      predicate - 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 a Collection for the specified subtype.
      Type Parameters:
      T - the incoming type
      R - the result type
      Parameters:
      iterable - an iterable whose values are of the source type
      subclass - the result type, only return elements if they are of this type
      Returns:
      a filtered Collection of 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 unmodifiable List of the elements.
      Type Parameters:
      T - the element type
      Parameters:
      collection - the collection to copy
      comparator - for sorting
      Returns:
      an unmodifiable List view of the elements.
    • copyAsImmutableList

      public static <T> List<T> copyAsImmutableList(@Nonnull Collection<? extends T> copy)
      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

      public static <T> Set<T> copyAsImmutableSet(@Nonnull Collection<? extends T> copy)
      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

      public static <K, V> Map<K,V> copyAsImmutableMap(@Nonnull Map<? extends K,? extends V> copy)
      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

      public static <T> T findFirstMatch(@Nonnull Iterable<? extends T> iterable, Predicate<T> predicate)
      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 return
      predicate - 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 elements
      predicate - to match the desired element
      Returns:
      the 0-based index of the first element that matches the predicate or -1 if none found
    • first

      public static <T> T first(@Nonnull Iterable<? extends T> iterable)
      Deprecated.
      Get the first element of a an Iterable in 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

      public static <K, R, S> Map<K,S> map(Map<K,R> map, Function<R,S> mapper)
      Deprecated.
      Take a map and eagerly transform all values into a new, immutable Map.
      Type Parameters:
      K - the key type
      R - the original value type
      S - the new value type
      Parameters:
      map - the original map
      mapper - the mapping function
      Returns:
      a new immutable map
      See Also: