Class BambooIterables

java.lang.Object
com.atlassian.bamboo.util.BambooIterables

public final class BambooIterables extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> Iterable<T>
    concat(@NotNull Iterable<? extends T> iterable, T object)
    Combines an iterable and an element into a single iterable.
    static <T> Iterable<T>
    concat(T object, @NotNull Iterable<? extends T> iterable)
    Combines an iterable and an element into a single iterable.
    static <T> Iterable<T>
    filter(@NotNull Iterable<T> iterable, @NotNull Predicate<? super T> predicate)
    Convenience method to filter an iterable using a predicate.
    static <T, E extends Throwable, F extends Throwable>
    T
    find(@NotNull Iterable<T> iterable, @NotNull DoubleThrowingPredicate<? super T,E,F> predicate, T defaultValue)
    Returns the first element in iterable that satisfies the given predicate, or defaultValue if none found.
    static <T, E extends Throwable>
    T
    find(@NotNull Iterable<T> iterable, @NotNull ThrowingPredicate<? super T,E> predicate, T defaultValue)
    Returns the first element in iterable that satisfies the given predicate, or defaultValue if none found.
    static <T> T
    find(Iterable<T> iterable, Predicate<? super T> predicate, @Nullable String exceptionMessage)
    Utility method to customize exception message thrown during stream manipulation.
    static <T> T
    getFirst(@NotNull Iterable<? extends T> iterable)
    Returns the first element in iterable or throws NoSuchElementException if iterable is empty.
    static <T> T
    getFirstOrElse(@Nullable Iterable<T> iterable, @NotNull Supplier<T> supplier)
    Returns the first element in iterable or obtains a default from the given supplier.
    static boolean
    hasSize(@NotNull Iterable<?> iterable, int size)
    Checks if the supplied iterable is of size size.
    static <T> @NotNull Iterable<T>
    iterable(@NotNull Supplier<Iterator<T>> supplier)
    Constructs an iterable for a supplier of iterators.
    static <T> boolean
    none(@NotNull Iterable<T> iterable, @NotNull Predicate<? super T> predicate)
    Returns true if no elements in iterable fulfill predicate.
    static <T> boolean
    removeAll(@NotNull Iterable<T> iterable, T o)
    Removes all occurrences of o from iterable.
    static <T> T
    removeFirst(@NotNull Iterable<T> iterable, @NotNull Predicate<T> predicate)
    Removes first object matching the predicate.
    static <T> @NotNull Stream<T>
    stream(@NotNull Iterable<T> iterable)
    Create a Stream from the given Iterable.
    static <T, U> Iterable<U>
    transform(@NotNull Iterable<T> iterable, @NotNull Function<? super T,U> function)
    Convenience method to transform an iterable using a function.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • find

      @Nullable public static <T, E extends Throwable> T find(@NotNull @NotNull Iterable<T> iterable, @NotNull @NotNull ThrowingPredicate<? super T,E> predicate, @Nullable T defaultValue) throws E
      Returns the first element in iterable that satisfies the given predicate, or defaultValue if none found.
      Throws:
      E extends Throwable
    • find

      @Nullable public static <T, E extends Throwable, F extends Throwable> T find(@NotNull @NotNull Iterable<T> iterable, @NotNull @NotNull DoubleThrowingPredicate<? super T,E,F> predicate, @Nullable T defaultValue) throws E, F
      Returns the first element in iterable that satisfies the given predicate, or defaultValue if none found.
      Throws:
      E extends Throwable
      F extends Throwable
    • find

      public static <T> T find(Iterable<T> iterable, Predicate<? super T> predicate, @Nullable @Nullable String exceptionMessage)
      Utility method to customize exception message thrown during stream manipulation.
    • none

      public static <T> boolean none(@NotNull @NotNull Iterable<T> iterable, @NotNull @NotNull Predicate<? super T> predicate)
      Returns true if no elements in iterable fulfill predicate.
    • concat

      public static <T> Iterable<T> concat(@NotNull @NotNull Iterable<? extends T> iterable, @NotNull T object)
      Combines an iterable and an element into a single iterable. The returned iterable has an iterator that traverses the elements in a, followed by b. The source iterator is not polled until necessary. The returned iterable's iterator supports remove() when the corresponding input iterator supports it.
    • concat

      public static <T> Iterable<T> concat(@NotNull T object, @NotNull @NotNull Iterable<? extends T> iterable)
      Combines an iterable and an element into a single iterable. The returned iterable has an iterator that returns a, followed by the elements in b. The source iterator is not polled until necessary. The returned iterable's iterator supports remove() when the corresponding input iterator supports it.
    • removeFirst

      @Nullable public static <T> T removeFirst(@NotNull @NotNull Iterable<T> iterable, @NotNull @NotNull Predicate<T> predicate)
      Removes first object matching the predicate.
    • hasSize

      public static boolean hasSize(@NotNull @NotNull Iterable<?> iterable, int size)
      Checks if the supplied iterable is of size size.
    • stream

      @NotNull public static <T> @NotNull Stream<T> stream(@NotNull @NotNull Iterable<T> iterable)
      Create a Stream from the given Iterable.
    • getFirst

      @NotNull public static <T> T getFirst(@NotNull @NotNull Iterable<? extends T> iterable)
      Returns the first element in iterable or throws NoSuchElementException if iterable is empty.
    • getFirstOrElse

      @NotNull public static <T> T getFirstOrElse(@Nullable @Nullable Iterable<T> iterable, @NotNull @NotNull Supplier<T> supplier)
      Returns the first element in iterable or obtains a default from the given supplier.
    • iterable

      @NotNull public static <T> @NotNull Iterable<T> iterable(@NotNull @NotNull Supplier<Iterator<T>> supplier)
      Constructs an iterable for a supplier of iterators.
    • removeAll

      public static <T> boolean removeAll(@NotNull @NotNull Iterable<T> iterable, @Nullable T o)
      Removes all occurrences of o from iterable. Returns true iff iterable was modified.
    • filter

      public static <T> Iterable<T> filter(@NotNull @NotNull Iterable<T> iterable, @NotNull @NotNull Predicate<? super T> predicate)
      Convenience method to filter an iterable using a predicate.
    • transform

      public static <T, U> Iterable<U> transform(@NotNull @NotNull Iterable<T> iterable, @NotNull @NotNull Function<? super T,U> function)
      Convenience method to transform an iterable using a function.