Class FluentIterableWrapper<E>
java.lang.Object
org.jenkinsci.plugins.github.util.FluentIterableWrapper<E>
- All Implemented Interfaces:
Iterable<E>
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public abstract class FluentIterableWrapper<E>
extends Object
implements Iterable<E>
Mostly copypaste from guava's FluentIterable
-
Method Summary
Modifier and TypeMethodDescriptionfinal FluentIterableWrapper
<E> Returns a fluent iterable whose iterators traverse first the elements of this fluent iterable, followed by those ofother
.final FluentIterableWrapper
<E> Returns the elements from this fluent iterable that satisfy a predicate.final <F extends E>
FluentIterableWrapper<F> Returns the elements from this fluent iterable that are instances of the supplied type.final com.google.common.base.Optional
<E> first()
Returns anOptional
containing the first element in this fluent iterable.final com.google.common.base.Optional
<E> firstMatch
(com.google.common.base.Predicate<? super E> predicate) Returns anOptional
containing the first element in this fluent iterable that satisfies the given predicate, if such an element exists.static <E> FluentIterableWrapper
<E> Returns a fluent iterable that wrapsiterable
, oriterable
itself if it is already aFluentIterable
.iterator()
toList()
Returns list from wrapped iterablefinal com.google.common.collect.ImmutableSet
<E> toSet()
Returns anImmutableSet
containing all of the elements from this fluent iterable with duplicates removed.final <T> FluentIterableWrapper
<T> Returns a fluent iterable that appliesfunction
to each element of this fluent iterable.<T> FluentIterableWrapper
<T> transformAndConcat
(com.google.common.base.Function<? super E, ? extends Iterable<? extends T>> function) Appliesfunction
to each element of this fluent iterable and returns a fluent iterable with the concatenated combination of results.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
iterator
-
from
Returns a fluent iterable that wrapsiterable
, oriterable
itself if it is already aFluentIterable
. -
append
Returns a fluent iterable whose iterators traverse first the elements of this fluent iterable, followed by those ofother
. The iterators are not polled until necessary.The returned iterable's
Iterator
supportsremove()
when the correspondingIterator
supports it. -
filter
@CheckReturnValue public final FluentIterableWrapper<E> filter(com.google.common.base.Predicate<? super E> predicate) Returns the elements from this fluent iterable that satisfy a predicate. The resulting fluent iterable's iterator does not supportremove()
. -
filter
Returns the elements from this fluent iterable that are instances of the supplied type. The resulting fluent iterable's iterator does not supportremove()
.- Since:
- 1.25.0
-
transform
public final <T> FluentIterableWrapper<T> transform(com.google.common.base.Function<? super E, T> function) Returns a fluent iterable that appliesfunction
to each element of this fluent iterable.The returned fluent iterable's iterator supports
remove()
if this iterable's iterator does. After a successfulremove()
call, this fluent iterable no longer contains the corresponding element. -
transformAndConcat
public <T> FluentIterableWrapper<T> transformAndConcat(com.google.common.base.Function<? super E, ? extends Iterable<? extends T>> function) Appliesfunction
to each element of this fluent iterable and returns a fluent iterable with the concatenated combination of results.function
returns an Iterable of results.The returned fluent iterable's iterator supports
remove()
if this function-returned iterables' iterator does. After a successfulremove()
call, the returned fluent iterable no longer contains the corresponding element. -
firstMatch
public final com.google.common.base.Optional<E> firstMatch(com.google.common.base.Predicate<? super E> predicate) Returns anOptional
containing the first element in this fluent iterable that satisfies the given predicate, if such an element exists.Warning: avoid using a
predicate
that matchesnull
. Ifnull
is matched in this fluent iterable, aNullPointerException
will be thrown. -
first
Returns anOptional
containing the first element in this fluent iterable. If the iterable is empty,Optional.absent()
is returned.- Throws:
NullPointerException
- if the first element is null; if this is a possibility, useiterator().next()
orIterables.getFirst(java.lang.Iterable<? extends T>, T)
instead.
-
toList
Returns list from wrapped iterable -
toSet
Returns anImmutableSet
containing all of the elements from this fluent iterable with duplicates removed.
-