List of usage examples for com.google.common.collect ImmutableSet.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:grakn.core.graql.executor.QueryExecutor.java
public ConceptMap undefine(GraqlUndefine query) { ImmutableSet.Builder<PropertyExecutor.Writer> executors = ImmutableSet.builder(); List<Statement> statements = query.statements().stream() .flatMap(statement -> statement.innerStatements().stream()).collect(Collectors.toList()); for (Statement statement : statements) { for (VarProperty property : statement.properties()) { executors.addAll(PropertyExecutor.definable(statement.var(), property).undefineExecutors()); }//www . ja va 2 s. c o m } return WriteExecutor.create(transaction, executors.build()).write(new ConceptMap()); }
From source file:grakn.core.graql.executor.QueryExecutor.java
public ConceptMap define(GraqlDefine query) { ImmutableSet.Builder<PropertyExecutor.Writer> executors = ImmutableSet.builder(); List<Statement> statements = query.statements().stream() .flatMap(statement -> statement.innerStatements().stream()).collect(Collectors.toList()); for (Statement statement : statements) { for (VarProperty property : statement.properties()) { executors.addAll(PropertyExecutor.definable(statement.var(), property).defineExecutors()); }//w w w . j ava 2s .c om } return WriteExecutor.create(transaction, executors.build()).write(new ConceptMap()); }
From source file:com.facebook.buck.android.NonPreDexedDexBuildable.java
/** @return the resulting set of ProGuarded classpath entries to dex. */ @VisibleForTesting/* w w w .jav a 2s . c o m*/ ImmutableSet<Path> addProguardCommands(Set<Path> classpathEntriesToDex, Set<Path> depsProguardConfigs, boolean skipProguard, ImmutableList.Builder<Step> steps, BuildableContext buildableContext, BuildContext buildContext) { // Create list of proguard Configs for the app project and its dependencies ImmutableSet.Builder<Path> proguardConfigsBuilder = ImmutableSet.builder(); proguardConfigsBuilder.addAll(depsProguardConfigs); if (proguardConfig.isPresent()) { proguardConfigsBuilder.add(buildContext.getSourcePathResolver().getAbsolutePath(proguardConfig.get())); } for (SourcePath aaptGeneratedProguardConfigFile : proguardConfigs) { proguardConfigsBuilder .add(buildContext.getSourcePathResolver().getAbsolutePath(aaptGeneratedProguardConfigFile)); } // Transform our input classpath to a set of output locations for each input classpath. // TODO(devjasta): the output path we choose is the result of a slicing function against // input classpath. This is fragile and should be replaced with knowledge of the BuildTarget. ImmutableMap<Path, Path> inputOutputEntries = classpathEntriesToDex.stream().collect( ImmutableMap.toImmutableMap(java.util.function.Function.identity(), (path) -> AndroidBinaryBuildable .getProguardOutputFromInputClasspath(getProguardInputsDir(), path))); // Run ProGuard on the classpath entries. ProGuardObfuscateStep.create(androidPlatformTarget, javaRuntimeLauncher.getCommandPrefix(buildContext.getSourcePathResolver()), getProjectFilesystem(), proguardJarOverride.isPresent() ? Optional .of(buildContext.getSourcePathResolver().getAbsolutePath(proguardJarOverride.get())) : Optional.empty(), proguardMaxHeapSize, proguardAgentPath, proguardConfigsBuilder.build(), sdkProguardConfig, optimizationPasses, proguardJvmArgs, inputOutputEntries, buildContext.getSourcePathResolver().getAllAbsolutePaths(additionalJarsForProguardAndDesugar), getProguardConfigDir(), buildableContext, buildContext, skipProguard, steps); // Apply the transformed inputs to the classpath (this will modify deps.classpathEntriesToDex // so that we're now dexing the proguarded artifacts). However, if we are not running // ProGuard then return the input classes to dex. if (skipProguard) { return ImmutableSet.copyOf(inputOutputEntries.keySet()); } else { return ImmutableSet.copyOf(inputOutputEntries.values()); } }
From source file:com.facebook.buck.apple.NewNativeTargetProjectMutator.java
void collectResourcePathsFromConstructorArgs(Set<AppleResourceDescription.Arg> resourceArgs, Set<AppleAssetCatalogDescription.Arg> assetCatalogArgs, ImmutableSet.Builder<Path> resourceFilesBuilder, ImmutableSet.Builder<Path> resourceDirsBuilder, ImmutableSet.Builder<Path> variantResourceFilesBuilder) { for (AppleResourceDescription.Arg arg : resourceArgs) { resourceFilesBuilder.addAll(Iterables.transform(arg.files, sourcePathResolver)); resourceDirsBuilder.addAll(Iterables.transform(arg.dirs, sourcePathResolver)); variantResourceFilesBuilder.addAll(Iterables.transform(arg.variants.get(), sourcePathResolver)); }/*from www . ja v a 2 s . c o m*/ for (AppleAssetCatalogDescription.Arg arg : assetCatalogArgs) { resourceDirsBuilder.addAll(Iterables.transform(arg.dirs, sourcePathResolver)); } }
From source file:org.eclipse.emf.compare.ide.ui.internal.logical.EMFResourceMappingMerger.java
/** * Iterates over the given diffs to collect the resources they impact. This will be called in case of * conflicts in order to know exactly which resources should be marked as conflicting. * // w w w . j a v a 2 s. c om * @param diffIterator * Iterator over the conflicting differences and their dependent diffs. * @return The uris of all resources impacted by conflicting differences. */ private Set<URI> collectConflictingResources(Iterator<Diff> diffIterator) { final Set<URI> conflictingURIs = new LinkedHashSet<URI>(); while (diffIterator.hasNext()) { final Diff diff = diffIterator.next(); final ImmutableSet.Builder<Diff> builder = ImmutableSet.builder(); if (diff.getConflict() != null) { builder.addAll(diff.getConflict().getDifferences()).add(diff); for (Diff conflictingDiff : builder.build()) { final Match next = conflictingDiff.getMatch(); final URI leftURI = resourceURIorNull(next.getLeft()); final URI rightURI = resourceURIorNull(next.getRight()); final URI originURI = resourceURIorNull(next.getOrigin()); if (leftURI != null) { conflictingURIs.add(leftURI); } if (rightURI != null) { conflictingURIs.add(rightURI); } if (originURI != null) { conflictingURIs.add(originURI); } } } } return conflictingURIs; }
From source file:com.google.devtools.build.lib.rules.objc.J2ObjcAspect.java
private ConfiguredAspect java(ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters) throws InterruptedException { JavaCompilationArgsProvider compilationArgsProvider = base.getProvider(JavaCompilationArgsProvider.class); JavaSourceInfoProvider sourceInfoProvider = base.getProvider(JavaSourceInfoProvider.class); JavaGenJarsProvider genJarProvider = base.getProvider(JavaGenJarsProvider.class); ImmutableSet.Builder<Artifact> javaSourceFilesBuilder = ImmutableSet.builder(); ImmutableSet.Builder<Artifact> javaSourceJarsBuilder = ImmutableSet.builder(); if (sourceInfoProvider != null) { javaSourceFilesBuilder.addAll(sourceInfoProvider.getSourceFiles()); if (ruleContext.getFragment(J2ObjcConfiguration.class).experimentalSrcJarProcessing()) { javaSourceJarsBuilder.addAll(sourceInfoProvider.getSourceJars()) .addAll(sourceInfoProvider.getSourceJarsForJarFiles()); } else {/* w w w. j a v a2 s . c o m*/ // The old source jar support treates source jars as source files, in the sense that // we generate a single concatenated ObjC header and source files for all sources inside // a given Java source jar. javaSourceFilesBuilder.addAll(sourceInfoProvider.getSourceJars()) .addAll(sourceInfoProvider.getSourceJarsForJarFiles()); } } if (genJarProvider != null && genJarProvider.getGenSourceJar() != null) { javaSourceJarsBuilder.add(genJarProvider.getGenSourceJar()); } ImmutableSet<Artifact> javaSourceFiles = javaSourceFilesBuilder.build(); ImmutableSet<Artifact> javaSourceJars = javaSourceJarsBuilder.build(); J2ObjcSource j2ObjcSource = javaJ2ObjcSource(ruleContext, javaSourceFiles, javaSourceJars); J2ObjcMappingFileProvider depJ2ObjcMappingFileProvider = depJ2ObjcMappingFileProvider(ruleContext); J2ObjcMappingFileProvider directJ2ObjcMappingFileProvider; if (Iterables.isEmpty(j2ObjcSource.getObjcSrcs())) { directJ2ObjcMappingFileProvider = new J2ObjcMappingFileProvider.Builder().build(); } else { directJ2ObjcMappingFileProvider = createJ2ObjcTranspilationAction(ruleContext, javaSourceFiles, javaSourceJars, depJ2ObjcMappingFileProvider, compilationArgsProvider, j2ObjcSource); } return buildAspect(base, ruleContext, parameters, j2ObjcSource, directJ2ObjcMappingFileProvider, JAVA_DEPENDENT_ATTRIBUTES); }
From source file:com.facebook.buck.apple.project_generator.NewNativeTargetProjectMutator.java
private void collectResourcePathsFromConstructorArgs(Set<AppleResourceDescription.Arg> resourceArgs, Set<AppleAssetCatalogDescription.Arg> assetCatalogArgs, Set<AppleWrapperResourceArg> resourcePathArgs, ImmutableSet.Builder<Path> resourceFilesBuilder, ImmutableSet.Builder<Path> resourceDirsBuilder, ImmutableSet.Builder<Path> variantResourceFilesBuilder) { for (AppleResourceDescription.Arg arg : resourceArgs) { resourceFilesBuilder.addAll(Iterables.transform(arg.files, sourcePathResolver)); resourceDirsBuilder.addAll(Iterables.transform(arg.dirs, sourcePathResolver)); variantResourceFilesBuilder.addAll(Iterables.transform(arg.variants, sourcePathResolver)); }/*from w w w . j a v a2 s. c o m*/ for (AppleAssetCatalogDescription.Arg arg : assetCatalogArgs) { resourceDirsBuilder.addAll(Iterables.transform(arg.dirs, sourcePathResolver)); } for (AppleWrapperResourceArg arg : resourcePathArgs) { resourceDirsBuilder.add(arg.path); } }
From source file:org.apache.abdera2.activities.model.ASObject.java
/** * Returns a union of all known IDs for this object.. specifically, * this is a union of the "id", "downstreamDuplicates" and "upstreamDuplicates" * properties/*from w ww.j a va2 s. c o m*/ */ public Iterable<String> getKnownIds() { ImmutableSet.Builder<String> list = ImmutableSet.builder(); if (has("id")) list.add(getId()); list.addAll(checkEmpty(getDownstreamDuplicates())); list.addAll(checkEmpty(getUpstreamDuplicates())); return list.build(); }
From source file:com.facebook.buck.android.SplitZipStep.java
/** * Construct a {@link Set} of internal class names that must go into the primary dex. * <p/>//from w ww.j ava 2 s .c o m * @return ImmutableSet of class internal names. */ private ImmutableSet<String> getRequiredPrimaryDexClassNames(ExecutionContext context, ProguardTranslatorFactory translatorFactory, Supplier<ImmutableList<ClassNode>> classesSupplier) throws IOException { ImmutableSet.Builder<String> builder = ImmutableSet.builder(); Optional<Path> primaryDexClassesFile = dexSplitMode.getPrimaryDexClassesFile() .transform(SourcePaths.TO_PATH); if (primaryDexClassesFile.isPresent()) { Iterable<String> classes = FluentIterable .from(context.getProjectFilesystem().readLines(primaryDexClassesFile.get())) .transform(STRING_TRIM).filter(IS_NEITHER_EMPTY_NOR_COMMENT); builder.addAll(classes); } // If there is a scenario file but overflow is not allowed, then the scenario dependencies // are required, and therefore get added here. if (!dexSplitMode.isPrimaryDexScenarioOverflowAllowed() && primaryDexScenarioFile.isPresent()) { addScenarioClasses(context, translatorFactory, classesSupplier, builder); } return ImmutableSet.copyOf(builder.build()); }
From source file:com.facebook.buck.apple.AppleBinaryDescription.java
@Override public <A extends Arg, U> Optional<U> createMetadata(BuildTarget buildTarget, BuildRuleResolver resolver, A args, Class<U> metadataClass) throws NoSuchBuildTargetException { if (!metadataClass.isAssignableFrom(FrameworkDependencies.class)) { CxxBinaryDescription.Arg delegateArg = delegate.createUnpopulatedConstructorArg(); AppleDescriptions.populateCxxBinaryDescriptionArg( new SourcePathResolver(new SourcePathRuleFinder(resolver)), delegateArg, args, buildTarget); return delegate.createMetadata(buildTarget, resolver, delegateArg, metadataClass); }//from www . ja va 2 s.c om Optional<Flavor> cxxPlatformFlavor = delegate.getCxxPlatforms().getFlavor(buildTarget); Preconditions.checkState(cxxPlatformFlavor.isPresent(), "Could not find cxx platform in:\n%s", Joiner.on(", ").join(buildTarget.getFlavors())); ImmutableSet.Builder<SourcePath> sourcePaths = ImmutableSet.builder(); for (BuildTarget dep : args.deps) { Optional<FrameworkDependencies> frameworks = resolver.requireMetadata( BuildTarget.builder(dep).addFlavors(AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR) .addFlavors(cxxPlatformFlavor.get()).build(), FrameworkDependencies.class); if (frameworks.isPresent()) { sourcePaths.addAll(frameworks.get().getSourcePaths()); } } return Optional.of(metadataClass.cast(FrameworkDependencies.of(sourcePaths.build()))); }