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(Iterable<? extends T> a, Iterable<? extends T> b) 

Source Link

Document

Combines two iterables into a single iterable.

Usage

From source file:com.github.steveash.typedconfig.resolver.ValueResolverRegistry.java

public static ValueResolverRegistry makeRegistryWithUserTypes(
        Iterable<? extends ValueResolverFactory> userTypes) {
    return new ValueResolverRegistry(Iterables.concat(userTypes, builtInTypes));
}

From source file:org.polarsys.reqcycle.utils.collect.IterableFactory.java

/**
 * Creates a depth wise iterable that concats all the iterables created by the call of createIterable on each of the starting elements.
 *///from   w w  w .  ja  v  a  2 s.c  o m
public static <T> Iterable<T> createIterable(Iterable<T> startingElements,
        Iterable<? extends Picker<T>> pickers) {
    Iterable<T> result = Collections.emptyList();
    for (T t : startingElements) {
        Iterable<T> tIterable = createIterable(t, pickers);
        result = Iterables.concat(result, tIterable);
    }
    return result;
}

From source file:org.apache.druid.query.expression.LookupEnabledTestExprMacroTable.java

private LookupEnabledTestExprMacroTable() {
    super(Lists/*  w ww. ja v a 2s.co  m*/
            .newArrayList(Iterables.concat(TestExprMacroTable.INSTANCE.getMacros(), Collections.singletonList(
                    new LookupExprMacro(createTestLookupReferencesManager(ImmutableMap.of("foo", "xfoo")))))));
}

From source file:com.google.gerrit.server.project.RefUtil.java

public static RevWalk verifyConnected(Repository repo, ObjectId revid) throws InvalidRevisionException {
    try {// w ww  . j  a v  a2 s.co  m
        ObjectWalk rw = new ObjectWalk(repo);
        try {
            rw.markStart(rw.parseCommit(revid));
        } catch (IncorrectObjectTypeException err) {
            throw new InvalidRevisionException();
        }
        RefDatabase refDb = repo.getRefDatabase();
        Iterable<Ref> refs = Iterables.concat(refDb.getRefs(Constants.R_HEADS).values(),
                refDb.getRefs(Constants.R_TAGS).values());
        Ref rc = refDb.exactRef(RefNames.REFS_CONFIG);
        if (rc != null) {
            refs = Iterables.concat(refs, Collections.singleton(rc));
        }
        for (Ref r : refs) {
            try {
                rw.markUninteresting(rw.parseAny(r.getObjectId()));
            } catch (MissingObjectException err) {
                continue;
            }
        }
        rw.checkConnectivity();
        return rw;
    } catch (IncorrectObjectTypeException | MissingObjectException err) {
        throw new InvalidRevisionException();
    } catch (IOException err) {
        log.error("Repository \"" + repo.getDirectory() + "\" may be corrupt; suggest running git fsck", err);
        throw new InvalidRevisionException();
    }
}

From source file:net.automatalib.automata.fsa.FiniteStateAcceptor.java

@Override
default Boolean computeSuffixOutput(Iterable<? extends I> prefix, Iterable<? extends I> suffix) {
    Iterable<I> input = Iterables.concat(prefix, suffix);
    return computeOutput(input);
}

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

public Iterable<Function> getFunctions() {
    if (timestamp != null && timeToLive != null)
        return Iterables.concat(timestamp.getFunctions(), timeToLive.getFunctions());
    else if (timestamp != null)
        return timestamp.getFunctions();
    else if (timeToLive != null)
        return timeToLive.getFunctions();
    else/*from w w  w  .j av  a  2 s  .  c o m*/
        return Collections.emptySet();
}

From source file:com.synflow.core.transformations.VarTransformation.java

@Override
public Void caseEntity(Entity entity) {
    for (Port port : Iterables.concat(entity.getInputs(), entity.getOutputs())) {
        doSwitch(port);/*  w  w w.j  a  v  a 2  s .c o m*/
    }

    for (Var var : Iterables.concat(entity.getParameters(), entity.getVariables())) {
        doSwitch(var);
    }

    for (Procedure procedure : entity.getProcedures()) {
        visitProcedure(procedure);
    }

    return DONE;
}

From source file:com.spotify.heroic.suggest.TagKeyCount.java

public static Collector<TagKeyCount, TagKeyCount> reduce(final OptionalLimit limit,
        final OptionalLimit exactLimit) {
    return groups -> {
        final List<RequestError> errors1 = new ArrayList<>();
        final HashMap<String, Suggestion> suggestions = new HashMap<>();
        boolean limited = false;

        for (final TagKeyCount g : groups) {
            errors1.addAll(g.errors);/*  w ww  .  j  a v  a2 s  .  c om*/

            for (final Suggestion s : g.suggestions) {
                final Suggestion replaced = suggestions.put(s.key, s);

                if (replaced == null) {
                    continue;
                }

                final Optional<Set<String>> exactValues;

                if (s.exactValues.isPresent() && replaced.exactValues.isPresent()) {
                    exactValues = Optional
                            .<Set<String>>of(ImmutableSet
                                    .copyOf(Iterables.concat(s.exactValues.get(), replaced.exactValues.get())))
                            .filter(set -> !exactLimit.isGreater(set.size()));
                } else {
                    exactValues = Optional.empty();
                }

                suggestions.put(s.key, new Suggestion(s.key, s.count + replaced.count, exactValues));
            }

            limited = limited || g.limited;
        }

        final List<Suggestion> list = new ArrayList<>(suggestions.values());
        Collections.sort(list);

        return new TagKeyCount(errors1, limit.limitList(list), limited || limit.isGreater(list.size()));
    };
}

From source file:org.litecoinj.crypto.HDUtils.java

/** Convert to a string path, starting with "M/" */
public static String formatPath(List<ChildNumber> path) {
    return PATH_JOINER.join(Iterables.concat(Collections.singleton("M"), path));
}

From source file:com.google.template.soy.shared.internal.InternalPlugins.java

/** Returns a map (whose key is the name of the function) of the functions shipped with Soy. */
public static ImmutableMap<String, SoySourceFunction> internalFunctionMap(final SoyScopedData soyScopedData) {
    Supplier<BidiGlobalDir> bidiProvider = new Supplier<BidiGlobalDir>() {
        @Override//w w w  . j a v a 2 s  .com
        public BidiGlobalDir get() {
            return soyScopedData.getBidiGlobalDir();
        }
    };
    // TODO(b/19252021): Include BuiltInFunctions
    return fromFunctions(Iterables.concat(BasicFunctions.functions(), BidiFunctions.functions(bidiProvider)));
}