List of usage examples for com.google.common.collect ImmutableSet isEmpty
boolean isEmpty();
From source file:net.femtoparsec.remote.impl.DefaultViewDifference.java
DefaultViewDifference(View firstView, View secondView, ImmutableSet<Address> newMembers, ImmutableSet<Address> leftMembers, ImmutableSet<Address> unchangedMembers) { this.firstView = firstView; this.secondView = secondView; this.newMembers = newMembers; this.leftMembers = leftMembers; this.unchangedMembers = unchangedMembers; this.sameMembers = newMembers.isEmpty() && leftMembers.isEmpty(); }
From source file:com.google.devtools.build.lib.remote.GrpcRemoteCache.java
/** * Put the file contents cache if it is not already in it. No-op if the file is already stored in * cache. The given path must be a full absolute path. * * @return The key for fetching the file contents blob from cache. */// ww w .ja v a 2 s. co m Digest uploadFileContents(ActionInput input, Path execRoot, MetadataProvider inputCache) throws IOException, InterruptedException { Digest digest = Digests.getDigestFromInputCache(input, inputCache); ImmutableSet<Digest> missing = getMissingDigests(ImmutableList.of(digest)); if (!missing.isEmpty()) { uploader.uploadBlob(new Chunker(input, inputCache, execRoot)); } return digest; }
From source file:com.google.devtools.build.lib.rules.objc.ObjcBundleLibrary.java
private Bundling bundling(RuleContext ruleContext, ObjcCommon common) { IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext); AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); ImmutableSet<TargetDeviceFamily> families = null; List<String> rawFamilies = ruleContext.attributes().get(FAMILIES_ATTR, Type.STRING_LIST); try {/*from w w w .j a va2 s. c o m*/ families = ImmutableSet.copyOf(TargetDeviceFamily.fromNamesInRule(rawFamilies)); } catch (InvalidFamilyNameException | RepeatedFamilyNameException e) { families = ImmutableSet.of(); } if (families.isEmpty()) { ruleContext.attributeError(FAMILIES_ATTR, ReleaseBundling.INVALID_FAMILIES_ERROR); } return new Bundling.Builder().setName(ruleContext.getLabel().getName()) .setArchitecture(appleConfiguration.getIosCpu()).setBundleDirFormat("%s.bundle") .setObjcProvider(common.getObjcProvider()).addInfoplistInputFromRule(ruleContext) .setIntermediateArtifacts(intermediateArtifacts) .setMinimumOsVersion(appleConfiguration.getMinimumOsForPlatformType(PlatformType.IOS)) .setTargetDeviceFamilies(families).build(); }
From source file:com.facebook.buck.ide.intellij.ModuleBuildContext.java
/** * Record a dependency on a {@link BuildTarget}. The dependency's type will be merged if multiple * {@link TargetNode}s refer to it or if multiple TargetNodes include sources from the same * directory./*ww w .j a va 2 s . co m*/ * * @param sourcePaths the {@link Path}s to sources which need this dependency to build. Can be * empty. * @param buildTargets the {@link BuildTarget}s to depend on * @param dependencyType what is the dependency needed for. */ public void addDeps(ImmutableSet<Path> sourcePaths, Iterable<BuildTarget> buildTargets, DependencyType dependencyType) { for (BuildTarget buildTarget : buildTargets) { if (circularDependencyInducingTargets.contains(buildTarget)) { continue; } if (sourcePaths.isEmpty()) { DependencyType.putWithMerge(dependencyTypeMap, buildTarget, dependencyType); } else { for (Path sourcePath : sourcePaths) { dependencyOriginMap.put(sourcePath, buildTarget); } } } }
From source file:com.facebook.buck.features.go.GoProjectCommandHelper.java
private TargetGraph getProjectGraphForIde(ImmutableSet<BuildTarget> passedInTargets) throws InterruptedException, BuildFileParseException, IOException { if (passedInTargets.isEmpty()) { return parser.buildTargetGraphWithConfigurationTargets(parsingContext, ImmutableList.of(ImmutableTargetNodePredicateSpec .of(BuildFileSpec.fromRecursivePath(Paths.get(""), cell.getRoot()))), targetConfiguration).getTargetGraph(); }/* w ww .j a v a2 s. c o m*/ return parser.buildTargetGraph(parsingContext, passedInTargets); }
From source file:com.facebook.buck.java.intellij.IjModuleFactory.java
/** * Create an {@link IjModule} form the supplied parameters. * * @param moduleBasePath the top-most directory the module is responsible for. * @param targetNodes set of nodes the module is to be created from. * @return nice shiny new module.//from w w w . j a v a2 s . c om */ @SuppressWarnings({ "unchecked", "rawtypes" }) public IjModule createModule(Path moduleBasePath, ImmutableSet<TargetNode<?>> targetNodes) { Preconditions.checkArgument(!targetNodes.isEmpty()); ImmutableSet<BuildTarget> moduleBuildTargets = FluentIterable.from(targetNodes) .transform(HasBuildTarget.TO_TARGET).toSet(); ModuleBuildContext context = new ModuleBuildContext(moduleBuildTargets); for (TargetNode<?> targetNode : targetNodes) { IjModuleRule<?> rule = Preconditions.checkNotNull(moduleRuleIndex.get(targetNode.getType())); rule.apply((TargetNode) targetNode, context); } return IjModule.builder().setModuleBasePath(moduleBasePath).setTargets(targetNodes) .addAllFolders(context.getSourceFolders()).putAllDependencies(context.getDependencies()) .setAndroidFacet(context.getAndroidFacet()) .addAllExtraClassPathDependencies(context.getExtraClassPathDependencies()).build(); }
From source file:com.jeffreybosboom.lyne.Puzzle.java
private Puzzle withEdgeSet(Pair<Node, Node> edge, ImmutableSet<Node.Kind> newEdgeSet) { assert neighbors(edge.first).anyMatch(Predicate.isEqual(edge.second)); assert edge.first.compareTo(edge.second) < 0; assert edgeSets.containsKey(edge) : "not an edge: " + edge; assert !newEdgeSet.contains(Node.Kind.OCTAGON); assert !newEdgeSet.isEmpty(); //TODO: no-change and ContradictionException checks could be moved here //from set and remove. ImmutableMap.Builder<Pair<Node, Node>, ImmutableSet<Node.Kind>> edgeSetBuilder = ImmutableMap.builder(); edgeSets.entrySet().stream().filter(e -> !e.getKey().equals(edge)).forEachOrdered(edgeSetBuilder::put); edgeSetBuilder.put(edge, newEdgeSet); return new Puzzle(this, edgeSetBuilder.build()); }
From source file:com.google.devtools.build.android.desugar.Desugar.java
/** * Desugar the classes that are generated on the fly when we are desugaring the classes in the * specified inputs.//from w w w . jav a 2 s .co m */ private void desugarAndWriteDumpedLambdaClassesToOutput(OutputFileProvider outputFileProvider, ClassLoader loader, ClassReaderFactory readerFactory, Builder<String> interfaceLambdaMethodCollector) throws IOException { ImmutableSet<String> interfaceLambdaMethods = interfaceLambdaMethodCollector.build(); checkState(!allowDefaultMethods || interfaceLambdaMethods.isEmpty(), "Desugaring with default methods enabled moved interface lambdas"); // Write out the lambda classes we generated along the way ImmutableMap<Path, LambdaInfo> lambdaClasses = lambdas.drain(); checkState(!options.onlyDesugarJavac9ForLint || lambdaClasses.isEmpty(), "There should be no lambda classes generated: %s", lambdaClasses.keySet()); for (Map.Entry<Path, LambdaInfo> lambdaClass : lambdaClasses.entrySet()) { try (InputStream bytecode = Files.newInputStream(dumpDirectory.resolve(lambdaClass.getKey()))) { ClassReader reader = rewriter.reader(bytecode); UnprefixingClassWriter writer = rewriter.writer(ClassWriter.COMPUTE_MAXS /*for invoking bridges*/); ClassVisitor visitor = createClassVisitorsForDumpedLambdaClasses(loader, readerFactory, interfaceLambdaMethods, lambdaClass.getValue(), writer); reader.accept(visitor, 0); String filename = rewriter.unprefix(lambdaClass.getValue().desiredInternalName()) + ".class"; outputFileProvider.write(filename, writer.toByteArray()); } } }
From source file:ratpack.server.internal.NettyHandlerAdapter.java
public NettyHandlerAdapter(Stopper stopper, Handler handler, LaunchConfig launchConfig) { this.handlers = new Handler[] { handler }; this.return404 = Handlers.notFound(); this.launchConfig = launchConfig; this.registry = buildBaseRegistry(stopper, launchConfig); this.addResponseTimeHeader = launchConfig.isTimeResponses(); this.applicationConstants = new DefaultContext.ApplicationConstants(launchConfig, new DefaultRenderController()); this.execController = launchConfig.getExecController(); this.execControl = execController.getControl(); if (launchConfig.isCompressResponses()) { ImmutableSet<String> blacklist = launchConfig.getCompressionMimeTypeBlackList(); this.shouldCompress = new ShouldCompressPredicate(launchConfig.getCompressionMinSize(), launchConfig.getCompressionMimeTypeWhiteList(), blacklist.isEmpty() ? ActivationBackedMimeTypes.getDefaultExcludedMimeTypes() : blacklist); } else {//w w w . j a v a2 s .co m this.shouldCompress = Predicates.alwaysFalse(); } }
From source file:de.metas.ui.web.handlingunits.process.WEBUI_Add_Batch_SerialNo_To_CUs.java
/** * @return true if at least one HU was removed */// ww w.j a va 2 s.c o m private boolean removeHUsIfDestroyed(final Collection<HuId> huIds) { final ImmutableSet<HuId> destroyedHUIds = huIds.stream().distinct().map(huId -> load(huId, I_M_HU.class)) .filter(Services.get(IHandlingUnitsBL.class)::isDestroyed).map(I_M_HU::getM_HU_ID) .map(HuId::ofRepoId).collect(ImmutableSet.toImmutableSet()); if (destroyedHUIds.isEmpty()) { return false; } final HUEditorView view = getView(); final boolean changes = view.removeHUIds(destroyedHUIds); return changes; }