Package com.atlassian.bamboo.util
Class BambooIterables
java.lang.Object
com.atlassian.bamboo.util.BambooIterables
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Iterable<T>
Combines an iterable and an element into a single iterable.static <T> Iterable<T>
Combines an iterable and an element into a single iterable.static <T> Iterable<T>
Convenience method to filter an iterable using a predicate.find
(@NotNull Iterable<T> iterable, @NotNull DoubleThrowingPredicate<? super T, E, F> predicate, T defaultValue) Returns the first element initerable
that satisfies the given predicate, ordefaultValue
if none found.static <T,
E extends Throwable>
Tfind
(@NotNull Iterable<T> iterable, @NotNull ThrowingPredicate<? super T, E> predicate, T defaultValue) Returns the first element initerable
that satisfies the given predicate, ordefaultValue
if none found.static <T> T
Utility method to customize exception message thrown during stream manipulation.static <T> T
Returns the first element initerable
or throwsNoSuchElementException
if iterable is empty.static <T> T
getFirstOrElse
(@Nullable Iterable<T> iterable, @NotNull Supplier<T> supplier) Returns the first element initerable
or obtains a default from the givensupplier
.static boolean
Checks if the supplied iterable is of size size.static <T> @NotNull Iterable<T>
Constructs an iterable for a supplier of iterators.static <T> boolean
Returns true if no elements in iterable fulfill predicate.static <T> boolean
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>
static <T,
U> Iterable<U> Convenience method to transform an iterable using a function.
-
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 EReturns the first element initerable
that satisfies the given predicate, ordefaultValue
if none found.- Throws:
E extends Throwable
-
find
@Nullable public static <T,E extends Throwable, T findF extends Throwable> (@NotNull @NotNull Iterable<T> iterable, @NotNull @NotNull DoubleThrowingPredicate<? super T, E, throws E, FF> predicate, @Nullable T defaultValue) Returns the first element initerable
that satisfies the given predicate, ordefaultValue
if none found. -
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
Checks if the supplied iterable is of size size. -
stream
-
getFirst
Returns the first element initerable
or throwsNoSuchElementException
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 initerable
or obtains a default from the givensupplier
. -
iterable
@NotNull public static <T> @NotNull Iterable<T> iterable(@NotNull @NotNull Supplier<Iterator<T>> supplier) Constructs an iterable for a supplier of iterators. -
removeAll
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.
-