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.xcode.xcodegen.Resources.java

public static Resources fromTargetControls(FileSystem fileSystem, PBXBuildFiles pbxBuildFiles,
        Iterable<TargetControl> targetControls) {
    ImmutableSetMultimap.Builder<TargetControl, PBXBuildFile> buildFiles = new ImmutableSetMultimap.Builder<>();

    for (TargetControl targetControl : targetControls) {
        List<PBXBuildFile> targetBuildFiles = new ArrayList<>();

        Iterable<String> simpleImports = Iterables.concat(targetControl.getXcassetsDirList(),
                targetControl.getBundleImportList());
        // Add .bundle, .xcassets directories to the Project Navigator so they are visible from within
        // Xcode.
        // Bundle imports are handled very similarly to asset catalogs, so we just add them with the
        // same logic. Xcode's automatic file type detection logic is smart enough to see it is a
        // bundle and link it properly, and add the {@code lastKnownFileType} property.
        for (String simpleImport : simpleImports) {
            targetBuildFiles.add(pbxBuildFiles.getStandalone(FileReference.of(simpleImport, SourceTree.GROUP)));
        }//  w w  w  . jav a2s  . c o m

        Iterables.addAll(targetBuildFiles, pbxBuildFiles.get(AggregateReferenceType.PBXVariantGroup,
                RelativePaths.fromStrings(fileSystem, targetControl.getGeneralResourceFileList())));

        // If this target is a binary, save the build files. Otherwise, we don't need them. The file
        // references we generated with fileObjects will be added to the main group later.
        if (!Equaling.of(ProductType.STATIC_LIBRARY, XcodeprojGeneration.productType(targetControl))) {
            buildFiles.putAll(targetControl, targetBuildFiles);
        }
    }

    return new Resources(buildFiles.build());
}

From source file:com.comphenix.protocol.compat.netty.LegacyProtocolRegistry.java

@Override
protected void initialize() {
    final Object[] protocols = enumProtocol.getEnumConstants();
    List<Map<Integer, Class<?>>> serverMaps = Lists.newArrayList();
    List<Map<Integer, Class<?>>> clientMaps = Lists.newArrayList();
    StructureModifier<Object> modifier = null;

    // Result/* www  . j  a  v a  2  s .  c  om*/
    Register result = new Register();

    for (Object protocol : protocols) {
        if (modifier == null)
            modifier = new StructureModifier<Object>(protocol.getClass().getSuperclass(), false);
        StructureModifier<Map<Integer, Class<?>>> maps = modifier.withTarget(protocol).withType(Map.class);

        serverMaps.add(maps.read(0));
        clientMaps.add(maps.read(1));
    }
    // Maps we have to occationally check have changed
    for (Map<Integer, Class<?>> map : Iterables.concat(serverMaps, clientMaps)) {
        result.containers.add(new MapContainer(map));
    }

    // Heuristic - there are more server packets than client packets
    if (sum(clientMaps) > sum(serverMaps)) {
        // Swap if this is violated
        List<Map<Integer, Class<?>>> temp = serverMaps;
        serverMaps = clientMaps;
        clientMaps = temp;
    }

    for (int i = 0; i < protocols.length; i++) {
        Enum<?> enumProtocol = (Enum<?>) protocols[i];
        Protocol equivalent = Protocol.fromVanilla(enumProtocol);

        // Associate known types
        associatePackets(result, serverMaps.get(i), equivalent, Sender.SERVER);
        associatePackets(result, clientMaps.get(i), equivalent, Sender.CLIENT);
    }

    // Exchange (thread safe, as we have only one writer)
    this.register = result;
}

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

public IterableView<T> concat(Iterable<? extends T> b) {
    return of(Iterables.concat(delegate(), b));
}

From source file:org.lenskit.basic.SimpleCachingItemScorer.java

@Nonnull
@Override//from   ww w . j  a va  2s . c  o  m
public ResultMap scoreWithDetails(long user, @Nonnull Collection<Long> items) {
    if (cachedId == user && cachedScores != null) {
        Set<Long> cachedItems = cachedScores.keySet();
        if (!cachedItems.containsAll(items)) {
            LongSet reqItems = LongUtils.packedSet(items);
            LongSortedSet diffItems = LongUtils.setDifference(reqItems, LongUtils.asLongSet(cachedItems));
            ResultMap newCache = scorer.scoreWithDetails(user, diffItems);
            cachedScores = Results.newResultMap(Iterables.concat(cachedScores, newCache));
        }
    } else {
        cachedScores = scorer.scoreWithDetails(user, items);
        cachedId = user;
    }
    return cachedScores;
}

From source file:com.torodb.core.language.AttributeReference.java

public AttributeReference append(List<? extends Key<?>> tail) {
    ImmutableList<Key<?>> newList = ImmutableList.copyOf(Iterables.concat(this.keys, tail));
    return new AttributeReference(newList);
}

From source file:com.torodb.torod.core.language.AttributeReference.java

public AttributeReference append(List<? extends Key> tail) {
    ImmutableList<Key> newList = ImmutableList.copyOf(Iterables.concat(this.keys, tail));
    return new AttributeReference(newList);
}

From source file:org.obiba.opal.web.project.permissions.ProjectPermissionsResource.java

/**
 * Get all permissions in the project./*  ww w  .  ja  v  a 2 s  . c o m*/
 *
 * @param domain
 * @param type
 * @return
 */
@GET
@Path("/_all")
public Iterable<Opal.Acl> getPermissions(@QueryParam("domain") @DefaultValue("opal") String domain,
        @QueryParam("type") SubjectType type) {

    // make sure project exists
    projectService.getProject(name);

    Iterable<SubjectAclService.Permissions> permissions = Iterables.concat(
            subjectAclService.getNodeHierarchyPermissions(domain, getNode(), type),
            Iterables.filter(subjectAclService.getNodeHierarchyPermissions(domain, "/datasource/" + name, type),
                    new MagmaPermissionsPredicate()));

    return Iterables.transform(permissions, PermissionsToAclFunction.INSTANCE);
}

From source file:org.apache.james.GuiceJamesServerImpl.java

public GuiceJamesServerImpl combineWith(Module... modules) {
    return new GuiceJamesServerImpl(
            Modules.combine(Iterables.concat(Arrays.asList(module), Arrays.asList(modules))));
}

From source file:com.facebook.buck.rage.DefaultExtraInfoCollector.java

@Override
public Optional<ExtraInfoResult> run() throws IOException, InterruptedException, ExtraInfoExecutionException {
    ImmutableList<String> extraInfoCommand = rageConfig.getExtraInfoCommand();
    if (extraInfoCommand.isEmpty()) {
        return Optional.empty();
    }/*from   ww w . j  a  v  a  2  s.co  m*/

    // TODO(ruibm): Potentially add the initial static launch dir here as well as any launch-*
    // logs buck is currently generating.
    Path rageExtraFilesDir = projectFilesystem.getBuckPaths().getLogDir().resolve("rage-extra-info");
    projectFilesystem.deleteRecursivelyIfExists(rageExtraFilesDir);
    projectFilesystem.mkdirs(rageExtraFilesDir);

    String extraInfoCommandOutput = runCommandAndGetStdout(
            Iterables.concat(extraInfoCommand,
                    ImmutableList.of("--output-dir", projectFilesystem.resolve(rageExtraFilesDir).toString())),
            projectFilesystem, processExecutor);

    ImmutableSet<Path> rageExtraFiles = projectFilesystem.getFilesUnderPath(rageExtraFilesDir);

    return Optional.of(
            ExtraInfoResult.builder().setExtraFiles(rageExtraFiles).setOutput(extraInfoCommandOutput).build());
}

From source file:org.apache.jackrabbit.oak.plugins.document.TieredDiffCache.java

@Nonnull
@Override
public Iterable<CacheStats> getStats() {
    return Iterables.concat(localCache.getStats(), memoryCache.getStats());
}