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 Type
    Method
    Description
    append(Iterable<? extends E> other)
    Returns a fluent iterable whose iterators traverse first the elements of this fluent iterable, followed by those of other.
    filter(com.google.common.base.Predicate<? super E> predicate)
    Returns the elements from this fluent iterable that satisfy a predicate.
    final <F extends E>
    FluentIterableWrapper<F>
    filter(Class<F> clazz)
    Returns the elements from this fluent iterable that are instances of the supplied type.
    final com.google.common.base.Optional<E>
    Returns an Optional 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 an Optional containing the first element in this fluent iterable that satisfies the given predicate, if such an element exists.
    static <E> FluentIterableWrapper<E>
    from(Iterable<E> iterable)
    Returns a fluent iterable that wraps iterable, or iterable itself if it is already a FluentIterable.
     
    Returns list from wrapped iterable
    final com.google.common.collect.ImmutableSet<E>
    Returns an ImmutableSet containing all of the elements from this fluent iterable with duplicates removed.
    final <T> FluentIterableWrapper<T>
    transform(com.google.common.base.Function<? super E,T> function)
    Returns a fluent iterable that applies function to each element of this fluent iterable.
    transformAndConcat(com.google.common.base.Function<? super E,? extends Iterable<? extends T>> function)
    Applies function 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

      public Iterator<E> iterator()
      Specified by:
      iterator in interface Iterable<E>
    • from

      public static <E> FluentIterableWrapper<E> from(Iterable<E> iterable)
      Returns a fluent iterable that wraps iterable, or iterable itself if it is already a FluentIterable.
    • append

      @CheckReturnValue public final FluentIterableWrapper<E> append(Iterable<? extends E> other)
      Returns a fluent iterable whose iterators traverse first the elements of this fluent iterable, followed by those of other. The iterators are not polled until necessary.

      The returned iterable's Iterator supports remove() when the corresponding Iterator 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 support remove().
    • filter

      @CheckReturnValue public final <F extends E> FluentIterableWrapper<F> filter(Class<F> clazz)
      Returns the elements from this fluent iterable that are instances of the supplied type. The resulting fluent iterable's iterator does not support remove().
      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 applies function to each element of this fluent iterable.

      The returned fluent iterable's iterator supports remove() if this iterable's iterator does. After a successful remove() 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)
      Applies function 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 successful remove() 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 an Optional containing the first element in this fluent iterable that satisfies the given predicate, if such an element exists.

      Warning: avoid using a predicate that matches null. If null is matched in this fluent iterable, a NullPointerException will be thrown.

    • first

      public final com.google.common.base.Optional<E> first()
      Returns an Optional 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, use iterator().next() or Iterables.getFirst(java.lang.Iterable<? extends T>, T) instead.
    • toList

      public List<E> toList()
      Returns list from wrapped iterable
    • toSet

      public final com.google.common.collect.ImmutableSet<E> toSet()
      Returns an ImmutableSet containing all of the elements from this fluent iterable with duplicates removed.