Example usage for com.google.common.collect Iterables concat

List of usage examples for com.google.common.collect Iterables concat

Introduction

In this page you can find the example usage for com.google.common.collect Iterables concat.

Prototype

public static <T> Iterable<T> concat(final Iterable<? extends Iterable<? extends T>> inputs) 

Source Link

Document

Combines multiple iterables into a single iterable.

Usage

From source file:com.datacoper.maven.util.CollectionsUtil.java

@SuppressWarnings("unchecked")
public static <E, T extends Collection<E>> List<E> concat(T... collections) {
    Iterable<E> concat = Iterables.concat(collections);

    List<E> list = new ArrayList<>();
    concat.forEach(item -> {/*ww w .  j av a2s.  c  o m*/
        list.add(item);
    });

    return list;
}

From source file:com.ignorelist.kassandra.steam.scraper.GameInfo.java

public static Iterable<String> getAllTags(Iterable<GameInfo> gameInfos) {
    return Iterables.concat(gameInfos);
}

From source file:com.google.devtools.build.xcode.util.Interspersing.java

/**
 * Inserts {@code what} before each item in {@code sequence}, returning a lazy sequence of twice
 * the length.//from   w ww . j a v  a2s .c o m
 */
public static <E> Iterable<E> beforeEach(final E what, Iterable<E> sequence) {
    Preconditions.checkNotNull(what);
    return Iterables.concat(Iterables.transform(sequence, new Function<E, Iterable<E>>() {
        @Override
        public Iterable<E> apply(E element) {
            return ImmutableList.of(what, element);
        }
    }));
}

From source file:com.opengamma.core.position.impl.PortfolioMapper.java

public static <T> List<T> flatMap(PortfolioNode node, PortfolioMapperFunction<List<T>> fn) {
    MappingCallback<List<T>, List<List<T>>> callback = new MappingCallback<List<T>, List<List<T>>>(fn,
            new ArrayList<List<T>>());
    List<List<T>> values = getValues(node, callback);
    return Lists.newArrayList(Iterables.concat(values));
}

From source file:org.apache.cassandra.cql3.Terms.java

public static Iterable<Function> getFunctions(Iterable<Term> terms) {
    if (terms == null)
        return Collections.emptySet();

    return Iterables.concat(Iterables.transform(terms, TO_FUNCTION_ITERABLE));
}

From source file:com.metamx.common.guava.FunctionalIterable.java

public static <T> FunctionalIterable<T> fromConcatenation(Iterable<T>... delegates) {
    return new FunctionalIterable<>(Iterables.concat(delegates));
}

From source file:sg.atom.utils._beta.functional.FunctionalIterable.java

public static <T> FunctionalIterable<T> fromConcatenation(Iterable<T>... delegates) {
    return new FunctionalIterable<T>(Iterables.concat(delegates));
}

From source file:see.util.Reduce.java

/**
 * Apply a function to each element of a collection, and concatenate results.
 * Operation is lazy - collections won't be queried in process.
 *
 * @param initial initial collection//from  w  ww. ja  v a 2 s .com
 * @param f function, which from element of initial collection to separate collection
 * @param <A> initial collection type
 * @param <B> resulting collection type
 * @return lazy collection, formed from applying function and concatenating results.
 */
public static <A, B> Iterable<B> flatMap(Iterable<A> initial, Function<? super A, ? extends Iterable<B>> f) {
    return Iterables.concat(Iterables.transform(initial, f));
}

From source file:springfox.documentation.service.Tags.java

public static Set<Tag> toTags(Multimap<String, ApiListing> apiListings) {
    Iterable<ApiListing> allListings = Iterables.concat(nullToEmptyMultimap(apiListings).asMap().values());
    List<Tag> tags = from(allListings).transformAndConcat(collectTags()).toList();
    TreeSet<Tag> tagSet = newTreeSet(tagNameComparator());
    tagSet.addAll(tags);//from   w w w  .j  a va 2 s  .co m
    return tagSet;
}

From source file:com.metamx.common.guava.FunctionalIterable.java

public static <T> FunctionalIterable<T> fromConcatenation(Iterable<Iterable<T>> delegates) {
    return new FunctionalIterable<>(Iterables.concat(delegates));
}