Package com.atlassian.bamboo.util
Class BambooIterables
- java.lang.Object
-
- com.atlassian.bamboo.util.BambooIterables
-
public final class BambooIterables extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods 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)
Equivalent ofIterables.filter(Iterable, com.google.common.base.Predicate)
relying on Java 8 stream API.static <T,E extends Throwable,F extends Throwable>
Tfind(@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
find(Iterable<T> iterable, com.google.common.base.Predicate<? super T> predicate, @Nullable String exceptionMessage)
Deprecated.since 6.2 usefind(Iterable, Predicate, String)
.static <T> T
find(Iterable<T> iterable, Predicate<? super T> predicate, @Nullable String exceptionMessage)
Utility method to customize exception message thrown byIterables.find(Iterable, com.google.common.base.Predicate)
.static <T> T
getFirst(@NotNull Iterable<? extends T> iterable)
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
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
none(@NotNull Iterable<T> iterable, com.google.common.base.Predicate<? super T> predicate)
Deprecated.since 6.2 usenone(Iterable, 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> T
removeFirst(@NotNull Iterable<T> iterable, com.google.common.base.Predicate<T> predicate)
Deprecated.since 6.2 useremoveFirst(Iterable, Predicate)
;static <T> @NotNull Stream<T>
stream(@NotNull Iterable<T> iterable)
static <T,U>
Iterable<U>transform(@NotNull Iterable<T> iterable, @NotNull Function<? super T,U> function)
Equivalent ofIterables.transform(Iterable, com.google.common.base.Function)
relying on Java 8 stream API.
-
-
-
Method Detail
-
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 extends Throwable
Returns 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,F extends Throwable> T find(@NotNull @NotNull Iterable<T> iterable, @NotNull @NotNull DoubleThrowingPredicate<? super T,E,F> predicate, @Nullable T defaultValue) throws E extends Throwable, F extends Throwable
Returns the first element initerable
that satisfies the given predicate, ordefaultValue
if none found.- Throws:
E extends Throwable
-
find
@Deprecated public static <T> T find(Iterable<T> iterable, com.google.common.base.Predicate<? super T> predicate, @Nullable @Nullable String exceptionMessage)
Deprecated.since 6.2 usefind(Iterable, Predicate, String)
.
-
find
public static <T> T find(Iterable<T> iterable, Predicate<? super T> predicate, @Nullable @Nullable String exceptionMessage)
Utility method to customize exception message thrown byIterables.find(Iterable, com.google.common.base.Predicate)
.
-
none
@Deprecated public static <T> boolean none(@NotNull @NotNull Iterable<T> iterable, @NotNull com.google.common.base.Predicate<? super T> predicate)
Deprecated.since 6.2 usenone(Iterable, Predicate)
.
-
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 @Deprecated public static <T> T removeFirst(@NotNull @NotNull Iterable<T> iterable, @NotNull com.google.common.base.Predicate<T> predicate)
Deprecated.since 6.2 useremoveFirst(Iterable, Predicate)
;
-
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)
-
getFirst
@NotNull public static <T> T getFirst(@NotNull @NotNull Iterable<? extends T> iterable)
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
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)
Equivalent ofIterables.filter(Iterable, com.google.common.base.Predicate)
relying on Java 8 stream API.
-
-