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.google.devtools.build.lib.rules.android.MergedAndroidAssets.java

static MergedAndroidAssets mergeFrom(AndroidDataContext dataContext, ParsedAndroidAssets parsed,
        AssetDependencies deps) throws InterruptedException {

    Artifact mergedAssets = dataContext.createOutputArtifact(AndroidRuleClasses.ANDROID_ASSETS_ZIP);

    BusyBoxActionBuilder builder = BusyBoxActionBuilder.create(dataContext, "MERGE_ASSETS");
    if (dataContext.getAndroidConfig().throwOnResourceConflict()) {
        builder.addFlag("--throwOnAssetConflict");
    }/*from ww  w  .  ja  v a  2 s.  c  o m*/

    builder.addOutput("--assetsOutput", mergedAssets)
            .addInput("--primaryData", AndroidDataConverter.MERGABLE_DATA_CONVERTER.map(parsed),
                    Iterables.concat(parsed.getAssets(), ImmutableList.of(parsed.getSymbols())))
            .addTransitiveFlag("--directData", deps.getDirectParsedAssets(),
                    AndroidDataConverter.MERGABLE_DATA_CONVERTER)
            .addTransitiveFlag("--data", deps.getTransitiveParsedAssets(),
                    AndroidDataConverter.MERGABLE_DATA_CONVERTER)
            .addTransitiveInputValues(deps.getTransitiveAssets())
            .addTransitiveInputValues(deps.getTransitiveSymbols())
            .buildAndRegister("Merging Android assets", "AndroidAssetMerger");

    return of(parsed, mergedAssets, deps);
}

From source file:jhc.redsniff.webdriver.finders.OrFinder.java

private static <T> CollectionOf<T> concat(CollectionOf<T> a, CollectionOf<T> b) {
    if (a.isEmpty()) {
        return b;
    } else if (b.isEmpty()) {
        return a;
    } else {//from w  ww .j a  v a 2s . c  o  m
        return new CollectionOf<T>(Lists.newArrayList(Iterables.concat(a, b)));
    }
}

From source file:com.palantir.common.collect.IterableUtils.java

public static <T> Iterable<T> prepend(T a, Iterable<? extends T> b) {
    Preconditions.checkNotNull(b);/*from w w  w  . j  a  v a 2s  .co  m*/
    return Iterables.concat(Collections.singleton(a), b);
}

From source file:org.guiceyfruit.spring.SpringModule.java

/**
 * Returns a new Injector with support for
 * <a href="http://code.google.com/p/guiceyfruit/wiki/Annotations">Spring annotations and
 * lifecycle support</a> along with JSR 250 support included.
 *///w  ww.j av a  2  s.c  o m
public static Injector createInjector(Module... modules) {
    Iterable<? extends Module> iterable = Iterables.concat(Collections.singletonList(new SpringModule()),
            Arrays.asList(modules));

    return Guice.createInjector(iterable);
}

From source file:org.sonar.plugins.python.pylint.PylintArguments.java

private static String pylintVersion(Command command) {
    long timeout = 10000;
    CommandStreamConsumer out = new CommandStreamConsumer();
    CommandStreamConsumer err = new CommandStreamConsumer();
    CommandExecutor.create().execute(command, out, err, timeout);
    Iterable<String> outputLines = Iterables.concat(out.getData(), err.getData());
    for (String outLine : outputLines) {
        Matcher matcher = PYLINT_VERSION_PATTERN.matcher(outLine);
        if (matcher.matches()) {
            return matcher.group(1);
        }/*from  w w  w .ja va2s . c  o m*/
    }
    String message = "Failed to determine pylint version with command: \"" + command.toCommandLine()
            + "\", received " + Iterables.size(outputLines) + " line(s) of output:\n"
            + Joiner.on('\n').join(outputLines);
    throw new IllegalArgumentException(message);
}

From source file:brainleg.app.engine.visitor.ConsoleStringGeneratorVisitor.java

public void visit(EData data) {
    Collection<ELine> lines = Lists.newArrayList(Iterables.concat(data.getHeaders(), data.getTraces()));

    sb.append(Joiner.on("").join(Collections2.transform(lines, new Function<ELine, String>() {
        public String apply(ELine line) {
            return line.rawText;
        }//  w w w  .j  a va  2s  . co  m
    })));
}

From source file:org.apache.cassandra.utils.StatusLogger.java

public static void log() {
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();

    // everything from o.a.c.concurrent
    logger.info(String.format("%-25s%10s%10s", "Pool Name", "Active", "Pending"));
    Set<ObjectName> request, internal;
    try {/*from www. j a va  2 s.  c o  m*/
        request = server.queryNames(new ObjectName("org.apache.cassandra.request:type=*"), null);
        internal = server.queryNames(new ObjectName("org.apache.cassandra.internal:type=*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName objectName : Iterables.concat(request, internal)) {
        String poolName = objectName.getKeyProperty("type");
        IExecutorMBean threadPoolProxy = JMX.newMBeanProxy(server, objectName, IExecutorMBean.class);
        logger.info(String.format("%-25s%10s%10s", poolName, threadPoolProxy.getActiveCount(),
                threadPoolProxy.getPendingTasks()));
    }
    // one offs
    logger.info(String.format("%-25s%10s%10s", "CompactionManager", "n/a",
            CompactionManager.instance.getPendingTasks()));
    int pendingCommands = 0;
    for (int n : MessagingService.instance().getCommandPendingTasks().values()) {
        pendingCommands += n;
    }
    int pendingResponses = 0;
    for (int n : MessagingService.instance().getResponsePendingTasks().values()) {
        pendingResponses += n;
    }
    logger.info(String.format("%-25s%10s%10s", "MessagingService", "n/a",
            pendingCommands + "," + pendingResponses));

    // per-CF stats
    logger.info(String.format("%-25s%20s%20s%20s", "ColumnFamily", "Memtable ops,data", "Row cache size/cap",
            "Key cache size/cap"));
    for (ColumnFamilyStore cfs : ColumnFamilyStore.all()) {
        logger.info(String.format("%-25s%20s%20s%20s", cfs.table.name + "." + cfs.columnFamily,
                cfs.getMemtableColumnsCount() + "," + cfs.getMemtableDataSize(),
                cfs.getRowCacheSize() + "/" + cfs.getRowCacheCapacity(),
                cfs.getKeyCacheSize() + "/" + cfs.getKeyCacheCapacity()));
    }
}

From source file:com.facebook.buck.rules.keys.StringifyAlterRuleKey.java

@VisibleForTesting
static Iterable<Path> findAbsolutePaths(Object val) {
    if (val instanceof Path) {
        Path path = (Path) val;
        if (path.isAbsolute()) {
            return Collections.singleton(path);
        }//from  w  ww . j  av  a  2 s  .  c  om
    } else if (val instanceof PathSourcePath) {
        return findAbsolutePaths(((PathSourcePath) val).getRelativePath());
    } else if (val instanceof Iterable) {
        return FluentIterable.from((Iterable<?>) val)
                .transformAndConcat(StringifyAlterRuleKey::findAbsolutePaths);
    } else if (val instanceof Map) {
        Map<?, ?> map = (Map<?, ?>) val;
        Iterable<?> allSubValues = Iterables.concat(map.keySet(), map.values());
        return FluentIterable.from(allSubValues).transformAndConcat(StringifyAlterRuleKey::findAbsolutePaths);
    } else if (val instanceof Optional) {
        Optional<?> optional = (Optional<?>) val;
        if (optional.isPresent()) {
            return findAbsolutePaths(optional.get());
        }
    }

    return ImmutableList.of();
}

From source file:org.workhorse.exec.ctx.BaseMutableContext.java

/** {@inheritDoc} */
@Override
public Iterable<String> getNames() {
    return Iterables.concat(getConstants().keySet(), getVariables().keySet());
}

From source file:chess_.engine.classic.player.Player.java

Player(final Board board, final Collection<Move> playerLegals, final Collection<Move> opponentLegals) {
    this.board = board;
    this.playerKing = establishKing();
    this.legalMoves = ImmutableList
            .copyOf(Iterables.concat(playerLegals, calculateKingCastles(playerLegals, opponentLegals)));
    this.isInCheck = !Player.calculateAttacksOnTile(this.playerKing.getPiecePosition(), opponentLegals)
            .isEmpty();/*from  w w  w . j a va  2s  .  c o m*/
}