List of usage examples for com.google.common.collect FluentIterable transformAndConcat
@CheckReturnValue public <T> FluentIterable<T> transformAndConcat(Function<? super E, ? extends Iterable<? extends T>> function)
From source file:com.spectralogic.ds3client.helpers.strategy.blobstrategy.GetSequentialBlobStrategy.java
@Override public synchronized Iterable<JobPart> getWork() throws IOException, InterruptedException { // get chunks that have blobs ready for transfer from black pearl final MasterObjectList masterObjectListWithAvailableChunks = masterObjectListWithAvailableChunks(); final FluentIterable<Objects> chunks = FluentIterable .from(masterObjectListWithAvailableChunks.getObjects()); return chunks.transformAndConcat(new Function<Objects, Iterable<? extends JobPart>>() { @Nullable// ww w. j ava 2 s.co m @Override public Iterable<? extends JobPart> apply(@Nullable final Objects chunk) { return FluentIterable.from(chunk.getObjects()).transform(new Function<BulkObject, JobPart>() { @Nullable @Override public JobPart apply(@Nullable final BulkObject blob) { return new JobPart(client(), blob); } }); } }); }
From source file:org.testfx.service.query.impl.NodeQueryImpl.java
@Override public NodeQuery lookup(Function<Node, Set<Node>> function) { FluentIterable<Node> query = FluentIterable.from(parentNodes); query = query.filter(Predicates.notNull()); query = query.transformAndConcat(function); parentNodes = query.toSet();// w w w . j a va 2 s. com return this; }
From source file:io.crate.operation.collect.sources.InformationSchemaIterables.java
@Inject public InformationSchemaIterables(final Schemas schemas, FulltextAnalyzerResolver ftResolver, ClusterService clusterService) throws IOException { this.schemas = Suppliers.<Iterable<?>>ofInstance(schemas); FluentIterable<TableInfo> tablesIterable = FluentIterable.from(schemas) .transformAndConcat(new Function<SchemaInfo, Iterable<TableInfo>>() { @Nullable/*from w w w . j av a2 s .com*/ @Override public Iterable<TableInfo> apply(SchemaInfo input) { assert input != null; // filter out partitions return FluentIterable.from(input).filter(new Predicate<TableInfo>() { @Override public boolean apply(TableInfo input) { assert input != null; return !PartitionName.isPartition(input.ident().indexName()); } }); } }); tablesGetter = Suppliers.<Iterable<?>>ofInstance(tablesIterable); partitionsGetter = Suppliers.<Iterable<?>>ofInstance(new PartitionInfos(clusterService)); FluentIterable<ColumnContext> columnsIterable = tablesIterable .transformAndConcat(new Function<TableInfo, Iterable<ColumnContext>>() { @Nullable @Override public Iterable<ColumnContext> apply(TableInfo input) { assert input != null; return new ColumnsIterator(input); } }); columnsGetter = Suppliers.<Iterable<?>>ofInstance(columnsIterable); constraintsGetter = Suppliers.<Iterable<?>>ofInstance(tablesIterable.filter(new Predicate<TableInfo>() { @Override public boolean apply(@Nullable TableInfo input) { return input != null && input.primaryKey().size() > 0; } })); RoutineInfos routineInfos = new RoutineInfos(ftResolver); routinesGetter = Suppliers .<Iterable<?>>ofInstance(FluentIterable.from(routineInfos).filter(new Predicate<RoutineInfo>() { @Override public boolean apply(@Nullable RoutineInfo input) { return input != null; } })); featuresGetter = Suppliers.<Iterable<?>>ofInstance(new SqlFeaturesIterable()); }
From source file:com.facebook.buck.jvm.java.DefaultJavaLibrary.java
/** * Building a java_library() rule entails compiling the .java files specified in the srcs * attribute. They are compiled into a directory under {@link BuckPaths#getScratchDir()}. *///from ww w . ja va 2 s . c o m @Override public final ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) { ImmutableList.Builder<Step> steps = ImmutableList.builder(); FluentIterable<JavaLibrary> declaredClasspathDeps = JavaLibraryClasspathProvider .getJavaLibraryDeps(getDepsForTransitiveClasspathEntries()); // Always create the output directory, even if there are no .java files to compile because there // might be resources that need to be copied there. BuildTarget target = getBuildTarget(); Path outputDirectory = getClassesDir(target, getProjectFilesystem()); steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), outputDirectory)); SuggestBuildRules suggestBuildRule = DefaultSuggestBuildRules.createSuggestBuildFunction(JAR_RESOLVER, declaredClasspathDeps.toSet(), ImmutableSet.<JavaLibrary>builder().addAll(getTransitiveClasspathDeps()).add(this).build(), context.getActionGraph().getNodes()); // We don't want to add these to the declared or transitive deps, since they're only used at // compile time. Collection<Path> provided = JavaLibraryClasspathProvider.getJavaLibraryDeps(providedDeps) .transformAndConcat(JavaLibrary::getOutputClasspaths).filter(Objects::nonNull).toSet(); ProjectFilesystem projectFilesystem = getProjectFilesystem(); // NOPMD confused by lambda Iterable<Path> declaredClasspaths = declaredClasspathDeps .transformAndConcat(JavaLibrary::getOutputClasspaths).transform(projectFilesystem::resolve); // Only override the bootclasspath if this rule is supposed to compile Android code. ImmutableSortedSet<Path> declared = ImmutableSortedSet.<Path>naturalOrder().addAll(declaredClasspaths) .addAll(additionalClasspathEntries).addAll(provided).build(); // Make sure that this directory exists because ABI information will be written here. Step mkdir = new MakeCleanDirectoryStep(getProjectFilesystem(), getPathToAbiOutputDir()); steps.add(mkdir); // If there are resources, then link them to the appropriate place in the classes directory. JavaPackageFinder finder = context.getJavaPackageFinder(); if (resourcesRoot.isPresent()) { finder = new ResourcesRootPackageFinder(resourcesRoot.get(), finder); } steps.add(new CopyResourcesStep(getProjectFilesystem(), getResolver(), ruleFinder, target, resources, outputDirectory, finder)); steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), getOutputJarDirPath(target, getProjectFilesystem()))); // Only run javac if there are .java files to compile or we need to shovel the manifest file // into the built jar. if (!getJavaSrcs().isEmpty()) { ClassUsageFileWriter usedClassesFileWriter; if (trackClassUsage) { final Path usedClassesFilePath = getUsedClassesFilePath(getBuildTarget(), getProjectFilesystem()); depFileOutputPath = getProjectFilesystem().getPathForRelativePath(usedClassesFilePath); usedClassesFileWriter = new DefaultClassUsageFileWriter(usedClassesFilePath); buildableContext.recordArtifact(usedClassesFilePath); } else { usedClassesFileWriter = NoOpClassUsageFileWriter.instance(); } // This adds the javac command, along with any supporting commands. Path pathToSrcsList = BuildTargets.getGenPath(getProjectFilesystem(), getBuildTarget(), "__%s__srcs"); steps.add(new MkdirStep(getProjectFilesystem(), pathToSrcsList.getParent())); Path scratchDir = BuildTargets.getGenPath(getProjectFilesystem(), target, "lib__%s____working_directory"); steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), scratchDir)); Optional<Path> workingDirectory = Optional.of(scratchDir); ImmutableSortedSet<Path> javaSrcs = getJavaSrcs().stream().map(getResolver()::getRelativePath) .collect(MoreCollectors.toImmutableSortedSet()); compileStepFactory.createCompileToJarStep(context, javaSrcs, target, getResolver(), ruleFinder, getProjectFilesystem(), declared, outputDirectory, workingDirectory, pathToSrcsList, Optional.of(suggestBuildRule), postprocessClassesCommands, ImmutableSortedSet.of(outputDirectory), /* mainClass */ Optional.empty(), manifestFile.map(getResolver()::getAbsolutePath), outputJar.get(), usedClassesFileWriter, /* output params */ steps, buildableContext, classesToRemoveFromJar); } if (outputJar.isPresent()) { Path output = outputJar.get(); // No source files, only resources if (getJavaSrcs().isEmpty()) { steps.add( new JarDirectoryStep(getProjectFilesystem(), output, ImmutableSortedSet.of(outputDirectory), /* mainClass */ null, manifestFile.map(getResolver()::getAbsolutePath).orElse(null), true, classesToRemoveFromJar)); } buildableContext.recordArtifact(output); } JavaLibraryRules.addAccumulateClassNamesStep(this, buildableContext, steps); return steps.build(); }