List of usage examples for com.google.common.collect ImmutableMultimap values
@Override
public ImmutableCollection<V> values()
From source file:com.facebook.buck.core.rules.impl.SymlinkTree.java
/** * Creates an instance of {@link SymlinkTree} * * @param category A name used in the symlink steps * @param target The target for this rule * @param filesystem The filesystem that the tree lives on * @param root The directory to create symlinks in * @param links A map of path within the link tree to the target of the symlikm * @param directoriesToMerge A map of relative paths within the link tree into which files from * the value will be recursively linked. e.g. if a file at /tmp/foo/bar should be linked as * /tmp/symlink-root/subdir/bar, the map should contain {Paths.get("subdir"), * SourcePath(Paths.get("tmp", "foo")) } * @param ruleFinder Used to iterate over {@code directoriesToMerge} in order get the build time *///ww w . j av a 2s . c o m public SymlinkTree(String category, BuildTarget target, ProjectFilesystem filesystem, Path root, ImmutableMap<Path, SourcePath> links, ImmutableMultimap<Path, SourcePath> directoriesToMerge, SourcePathRuleFinder ruleFinder) { super(target, filesystem); this.category = category; this.directoriesToMerge = directoriesToMerge; this.buildDeps = directoriesToMerge.values().stream().map(ruleFinder::getRule).filter(Optional::isPresent) .map(Optional::get).collect(ImmutableSortedSet.toImmutableSortedSet(Ordering.natural())); Preconditions.checkState(!root.isAbsolute(), "Expected symlink tree root to be relative: %s", root); this.root = root; this.links = ImmutableSortedMap.copyOf(links); this.type = category + "_symlink_tree"; }
From source file:com.google.errorprone.bugpatterns.LambdaFunctionalInterface.java
private boolean methodCallsMeetConditions(Symbol sym, VisitorState state) { ImmutableMultimap<String, MethodInvocationTree> methodCallMap = methodCallsForSymbol(sym, getTopLevelClassTree(state)); if (methodCallMap.isEmpty()) { // no method invocations for this method, safe to refactor return true; }//from w w w . j a v a2 s.com for (MethodInvocationTree methodInvocationTree : methodCallMap.values()) { if (methodInvocationTree.getArguments().stream().filter(a -> Kind.LAMBDA_EXPRESSION.equals(a.getKind())) .filter(a -> hasFunctionAsArg(a, state)) .noneMatch(a -> isFunctionArgSubtypeOf(a, 0, state.getTypeFromString(JAVA_LANG_NUMBER), state) || isFunctionArgSubtypeOf(a, 1, state.getTypeFromString(JAVA_LANG_NUMBER), state))) { return false; } } return true; }
From source file:org.streamingpool.ext.tensorics.streamfactory.DetailedTensoricsExpressionStreamFactory.java
private <T, E extends Expression<T>> Flowable<DetailedExpressionResult<T, E>> resolvedStream( DetailedExpressionStreamId<T, E> id, DiscoveryService discoveryService) { E expression = id.expression();// w w w . j ava 2 s . c o m ResolvingContext initialCtx = id.initialContext(); Map<Expression<Object>, StreamId<Object>> streamIds = streamIdsFrom(id); ImmutableMultimap.Builder<StreamId<?>, Flowable<ExpToValue>> builder = ImmutableMultimap.builder(); for (Entry<Expression<Object>, StreamId<Object>> entry : streamIds.entrySet()) { Flowable<?> plainObservable = fromPublisher(discoveryService.discover(entry.getValue())); Flowable<ExpToValue> mappedObservable; mappedObservable = plainObservable.map(obj -> new ExpToValue(entry.getKey(), obj)); builder.put(entry.getValue(), mappedObservable); } ImmutableMultimap<StreamId<?>, Flowable<ExpToValue>> observableEntries = builder.build(); EvaluationStrategy evaluationStrategy = initialCtx .resolvedValueOf(Placeholder.ofClass(EvaluationStrategy.class)); Flowable<?> triggerObservable = triggerObservable(observableEntries, evaluationStrategy, discoveryService); return triggerObservable .withLatestFrom(observableEntries.values().toArray(new Flowable[] {}), CONTEXT_COMBINER) .map(ctx -> { EditableResolvingContext fullContext = Contexts.newResolvingContext(); fullContext.putAllNew(ctx); fullContext.putAllNew(initialCtx); return engine.resolveDetailed(expression, fullContext, EXCEPTION_HANDLING_STRATEGY); }); }
From source file:org.sosy_lab.cpachecker.util.precondition.segkro.RefineSolverBasedItp.java
private PredicatePrecision predicatesAsGlobalPrecision(final ImmutableList<BooleanFormula> pGlobalPreds, final ImmutableMultimap<CFANode, BooleanFormula> pLocalPreds) { Multimap<Pair<CFANode, Integer>, AbstractionPredicate> locationInstancePredicates = HashMultimap.create(); Multimap<CFANode, AbstractionPredicate> localPredicates = HashMultimap.create(); Multimap<String, AbstractionPredicate> functionPredicates = HashMultimap.create(); Collection<AbstractionPredicate> globalPredicates = Lists.newArrayList(); // TODO: Make the local predicates really local!! for (BooleanFormula f : pLocalPreds.values()) { AbstractionPredicate ap = amgr.makePredicate(f); globalPredicates.add(ap);/*from w ww . ja v a 2 s.c o m*/ } for (BooleanFormula f : pGlobalPreds) { AbstractionPredicate ap = amgr.makePredicate(f); globalPredicates.add(ap); } return new PredicatePrecision(locationInstancePredicates, localPredicates, functionPredicates, globalPredicates); }
From source file:com.google.devtools.build.lib.query2.output.ProtoOutputFormatter.java
/** Converts a logical {@link Target} object into a {@link Build.Target} protobuffer. */ @VisibleForTesting/*from w w w . j a va2s . c om*/ public Build.Target toTargetProtoBuffer(Target target) throws InterruptedException { Build.Target.Builder targetPb = Build.Target.newBuilder(); String location = getLocation(target, relativeLocations); if (target instanceof Rule) { Rule rule = (Rule) target; Build.Rule.Builder rulePb = Build.Rule.newBuilder().setName(rule.getLabel().toString()) .setRuleClass(rule.getRuleClass()); if (includeLocation()) { rulePb.setLocation(location); } Map<Attribute, Build.Attribute> serializedAttributes = Maps.newHashMap(); for (Attribute attr : rule.getAttributes()) { if ((!includeDefaultValues && !rule.isAttributeValueExplicitlySpecified(attr)) || !includeAttribute(rule, attr)) { continue; } Object flattenedAttributeValue = flattenAttributeValues(attr.getType(), getPossibleAttributeValues(rule, attr)); Build.Attribute serializedAttribute = AttributeFormatter.getAttributeProto(attr, flattenedAttributeValue, rule.isAttributeValueExplicitlySpecified(attr), /*encodeBooleanAndTriStateAsIntegerAndString=*/ true); rulePb.addAttribute(serializedAttribute); serializedAttributes.put(attr, serializedAttribute); } postProcess(rule, rulePb, serializedAttributes); Environment env = rule.getRuleClassObject().getRuleDefinitionEnvironment(); if (env != null && includeRuleDefinitionEnvironment()) { // The RuleDefinitionEnvironment is always defined for Skylark rules and // always null for non Skylark rules. rulePb.addAttribute(Build.Attribute.newBuilder().setName(RULE_IMPLEMENTATION_HASH_ATTR_NAME) .setType(ProtoUtils.getDiscriminatorFromType(Type.STRING)) .setStringValue(env.getTransitiveContentHashCode())); } ImmutableMultimap<Attribute, Label> aspectsDependencies = aspectResolver .computeAspectDependencies(target, dependencyFilter); // Add information about additional attributes from aspects. for (Entry<Attribute, Collection<Label>> entry : aspectsDependencies.asMap().entrySet()) { Attribute attribute = entry.getKey(); Collection<Label> labels = entry.getValue(); if (!includeAspectAttribute(attribute, labels)) { continue; } Object attributeValue = getAspectAttributeValue(attribute, labels); Build.Attribute serializedAttribute = AttributeFormatter.getAttributeProto(attribute, attributeValue, /*explicitlySpecified=*/ false, /*encodeBooleanAndTriStateAsIntegerAndString=*/ true); rulePb.addAttribute(serializedAttribute); } if (includeRuleInputsAndOutputs()) { // Add all deps from aspects as rule inputs of current target. for (Label label : aspectsDependencies.values()) { rulePb.addRuleInput(label.toString()); } // Include explicit elements for all direct inputs and outputs of a rule; // this goes beyond what is available from the attributes above, since it // may also (depending on options) include implicit outputs, // host-configuration outputs, and default values. for (Label label : rule.getLabels(dependencyFilter)) { rulePb.addRuleInput(label.toString()); } for (OutputFile outputFile : rule.getOutputFiles()) { Label fileLabel = outputFile.getLabel(); rulePb.addRuleOutput(fileLabel.toString()); } } for (String feature : rule.getFeatures()) { rulePb.addDefaultSetting(feature); } targetPb.setType(RULE); targetPb.setRule(rulePb); } else if (target instanceof OutputFile) { OutputFile outputFile = (OutputFile) target; Label label = outputFile.getLabel(); Rule generatingRule = outputFile.getGeneratingRule(); GeneratedFile.Builder output = GeneratedFile.newBuilder() .setGeneratingRule(generatingRule.getLabel().toString()).setName(label.toString()); if (includeLocation()) { output.setLocation(location); } targetPb.setType(GENERATED_FILE); targetPb.setGeneratedFile(output.build()); } else if (target instanceof InputFile) { InputFile inputFile = (InputFile) target; Label label = inputFile.getLabel(); Build.SourceFile.Builder input = Build.SourceFile.newBuilder().setName(label.toString()); if (includeLocation()) { input.setLocation(location); } if (inputFile.getName().equals("BUILD")) { Set<Label> subincludeLabels = new LinkedHashSet<>(); subincludeLabels.addAll(aspectResolver == null ? inputFile.getPackage().getSubincludeLabels() : aspectResolver.computeBuildFileDependencies(inputFile.getPackage(), BuildFileDependencyMode.SUBINCLUDE)); subincludeLabels.addAll(aspectResolver == null ? inputFile.getPackage().getSkylarkFileDependencies() : aspectResolver.computeBuildFileDependencies(inputFile.getPackage(), BuildFileDependencyMode.SKYLARK)); for (Label skylarkFileDep : subincludeLabels) { input.addSubinclude(skylarkFileDep.toString()); } for (String feature : inputFile.getPackage().getFeatures()) { input.addFeature(feature); } input.setPackageContainsErrors(inputFile.getPackage().containsErrors()); } for (Label visibilityDependency : target.getVisibility().getDependencyLabels()) { input.addPackageGroup(visibilityDependency.toString()); } for (Label visibilityDeclaration : target.getVisibility().getDeclaredLabels()) { input.addVisibilityLabel(visibilityDeclaration.toString()); } targetPb.setType(SOURCE_FILE); targetPb.setSourceFile(input); } else if (target instanceof FakeSubincludeTarget) { Label label = target.getLabel(); SourceFile.Builder input = SourceFile.newBuilder().setName(label.toString()); if (includeLocation()) { input.setLocation(location); } targetPb.setType(SOURCE_FILE); targetPb.setSourceFile(input.build()); } else if (target instanceof PackageGroup) { PackageGroup packageGroup = (PackageGroup) target; Build.PackageGroup.Builder packageGroupPb = Build.PackageGroup.newBuilder() .setName(packageGroup.getLabel().toString()); for (String containedPackage : packageGroup.getContainedPackages()) { packageGroupPb.addContainedPackage(containedPackage); } for (Label include : packageGroup.getIncludes()) { packageGroupPb.addIncludedPackageGroup(include.toString()); } targetPb.setType(PACKAGE_GROUP); targetPb.setPackageGroup(packageGroupPb); } else if (target instanceof EnvironmentGroup) { EnvironmentGroup envGroup = (EnvironmentGroup) target; Build.EnvironmentGroup.Builder envGroupPb = Build.EnvironmentGroup.newBuilder() .setName(envGroup.getLabel().toString()); for (Label env : envGroup.getEnvironments()) { envGroupPb.addEnvironment(env.toString()); } for (Label defaultEnv : envGroup.getDefaults()) { envGroupPb.addDefault(defaultEnv.toString()); } targetPb.setType(ENVIRONMENT_GROUP); targetPb.setEnvironmentGroup(envGroupPb); } else { throw new IllegalArgumentException(target.toString()); } return targetPb.build(); }