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:io.druid.server.metrics.MetricsModule.java

@Provides
@ManageLifecycle//  w w  w . j ava2  s. c  o m
public MonitorScheduler getMonitorScheduler(Supplier<DruidMonitorSchedulerConfig> config,
        MonitorsConfig monitorsConfig, Set<Class<? extends Monitor>> monitorSet, ServiceEmitter emitter,
        Injector injector) {
    List<Monitor> monitors = Lists.newArrayList();

    for (Class<? extends Monitor> monitorClass : Iterables.concat(monitorsConfig.getMonitors(), monitorSet)) {
        final Monitor monitor = injector.getInstance(monitorClass);

        log.info("Adding monitor[%s]", monitor);

        monitors.add(monitor);
    }

    return new MonitorScheduler(config.get(), Execs.scheduledSingleThreaded("MonitorScheduler-%s"), emitter,
            monitors);
}

From source file:org.gradle.api.internal.tasks.compile.daemon.DaemonGroovyCompiler.java

private DaemonForkOptions createGroovyForkOptions(GroovyJavaJointCompileSpec spec) {
    GroovyForkOptions options = spec.getGroovyCompileOptions().getForkOptions();
    // Ant is optional dependency of groovy(-all) module but mandatory dependency of Groovy compiler;
    // that's why we add it here. The following assumes that any Groovy compiler version supported by Gradle
    // is compatible with Gradle's current Ant version.
    Collection<File> antFiles = classPathRegistry.getClassPath("ANT").getAsFiles();
    Iterable<File> groovyFiles = Iterables.concat(spec.getGroovyClasspath(), antFiles);
    return new DaemonForkOptions(options.getMemoryInitialSize(), options.getMemoryMaximumSize(),
            options.getJvmArgs(), groovyFiles, SHARED_PACKAGES);
}

From source file:com.spotify.heroic.consumer.collectd.CollectdChannelHandler.java

@Override
protected void channelRead0(final ChannelHandlerContext ctx, final DatagramPacket msg) throws Exception {
    final Iterator<CollectdSample> samples = CollectdParser.parse(msg.content());

    while (samples.hasNext()) {
        final CollectdSample s = samples.next();

        final Set<Map.Entry<String, String>> base = ImmutableMap
                .of("host", s.getHost(), "plugin", s.getPlugin()).entrySet();

        final List<Ingestion.Request> ingestions;

        if (hostProcessor.isPresent()) {
            final Map<String, Object> parts = hostProcessor.get().parse(s.getHost());

            final Set<Map.Entry<String, String>> tags = ImmutableSet.copyOf(
                    Iterables.transform(parts.entrySet(), e -> Pair.of(e.getKey(), e.getValue().toString())));

            ingestions = types.convert(s, Iterables.concat(base, tags));
        } else {//from  w  w  w. ja  v a2s .co m
            ingestions = types.convert(s, base);
        }

        final List<AsyncFuture<Ingestion>> futures = new ArrayList<>();

        for (final Ingestion.Request w : ingestions) {
            futures.add(ingestion.write(w));
        }

        async.collectAndDiscard(futures);
    }
}

From source file:org.jboss.windup.config.condition.GraphCondition.java

/**
 * This sets the variable with the given name to the given value. If there is already a variable with the same name in the top-most stack frame,
 * we will combine them here./*from  w  ww  . j  av  a2  s .co m*/
 *
 * This helps in the case of multiple conditions tied together with "or" or "and".
 */
protected void setResults(GraphRewrite event, String variable, Iterable<? extends WindupVertexFrame> results) {
    Variables variables = Variables.instance(event);
    Iterable<? extends WindupVertexFrame> existingVariables = variables.findVariable(variable, 1);
    if (existingVariables != null) {
        variables.setVariable(variable, Iterables.concat(existingVariables, results));
    } else {
        variables.setVariable(variable, results);
    }
}

From source file:org.apache.james.transport.mailets.remote.delivery.DelaysAndMaxRetry.java

private static DelaysAndMaxRetry addExtraAttemptToLastDelay(int intendedMaxRetries, int extra,
        List<Delay> delayTimesList) throws MessagingException {
    if (delayTimesList.size() != 0) {
        Delay lastDelay = delayTimesList.get(delayTimesList.size() - 1);
        LOGGER.warn("Delay of {} msecs is now attempted: {} times", lastDelay.getDelayTimeInMs(),
                lastDelay.getAttempts());
        return new DelaysAndMaxRetry(intendedMaxRetries, ImmutableList.copyOf(Iterables.concat(
                Iterables.limit(delayTimesList, delayTimesList.size() - 1),
                ImmutableList.of(new Delay(lastDelay.getAttempts() + extra, lastDelay.getDelayTimeInMs())))));
    } else {/* www .j av a 2  s . co m*/
        throw new MessagingException("No delaytimes, cannot continue");
    }
}

From source file:com.google.devtools.build.lib.syntax.GlobList.java

/**
 * Concatenates two lists into a new GlobList. If either of the lists is a
 * GlobList, its GlobCriteria are preserved. Otherwise a simple GlobCriteria
 * is created to represent the fixed list.
 *//* w w w . j av a2 s. co  m*/
public static <T> GlobList<T> concat(List<? extends T> list1, List<? extends T> list2) {
    // we add the list to both includes and matches, preserving order
    Builder<GlobCriteria> criteriaBuilder = ImmutableList.<GlobCriteria>builder();
    if (list1 instanceof GlobList<?>) {
        criteriaBuilder.addAll(((GlobList<?>) list1).criteria);
    } else {
        criteriaBuilder.add(GlobCriteria.fromList(list1));
    }
    if (list2 instanceof GlobList<?>) {
        criteriaBuilder.addAll(((GlobList<?>) list2).criteria);
    } else {
        criteriaBuilder.add(GlobCriteria.fromList(list2));
    }
    List<T> matches = ImmutableList.copyOf(Iterables.concat(list1, list2));
    return new GlobList<>(criteriaBuilder.build(), matches);
}

From source file:org.gradle.model.internal.manage.schema.extract.StructStrategy.java

public StructStrategy(Factory<String> supportedTypeDescriptions) {
    this.supportedTypeDescriptions = supportedTypeDescriptions;

    Iterable<Method> ignoredMethods = Iterables.concat(Arrays.asList(Object.class.getMethods()),
            Arrays.asList(GroovyObject.class.getMethods()));
    this.ignoredMethods = ImmutableSet
            .copyOf(Iterables.transform(ignoredMethods, new Function<Method, Equivalence.Wrapper<Method>>() {
                public Equivalence.Wrapper<Method> apply(@Nullable Method input) {
                    return equivalence.wrap(input);
                }//  w w  w .  j  a  va 2  s. c om
            }));
}

From source file:com.facebook.buck.cxx.Omnibus.java

private static Iterable<NativeLinkable> getDeps(NativeLinkable nativeLinkable, CxxPlatform cxxPlatform) {
    return Iterables.concat(nativeLinkable.getNativeLinkableDepsForPlatform(cxxPlatform),
            nativeLinkable.getNativeLinkableExportedDepsForPlatform(cxxPlatform));
}

From source file:org.eclipse.sirius.diagram.ui.tools.internal.commands.emf.CopyToSiriusClipboardCommand.java

/**
 * This returns the collection of objects to be copied to the clipboard.
 *
 * @return the object to copy.//from  ww  w.j a v  a  2  s.com
 */
public Collection<?> getSourceObjects() {
    return Lists.newArrayList(Iterables.concat(dElementsToCopy, elementsToCopy));
}

From source file:com.groupon.jenkins.dynamic.build.api.BuildHistory.java

public Iterable<Build> getBuilds(String branch, final int count) {
    if ("All".equalsIgnoreCase(branch)) {
        branch = null;/*from   w  w  w .ja v  a  2 s .  c o  m*/
    }
    final Iterable<DynamicBuild> builds = isMyBuilds(branch)
            ? getDynamicBuildRepository().<DynamicBuild>getCurrentUserBuilds(this.dynamicProject, count, null)
            : getDynamicBuildRepository().<DynamicBuild>getLast(this.dynamicProject, count, branch, null);
    return Iterables.concat(getQueuedBuilds(), toUiBuilds(filterSkipped(builds)));
}