Java Code Examples for com.google.common.collect.SetMultimap#get()

The following examples show how to use com.google.common.collect.SetMultimap#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapKeyProcessingStep.java    From dagger2-sample with Apache License 2.0 6 votes vote down vote up
@Override
public void process(SetMultimap<Class<? extends Annotation>, Element> elementsByAnnotation) {
  for (Element element : elementsByAnnotation.get(MapKey.class)) {
    ValidationReport<Element> mapKeyReport = mapKeyValidator.validate(element);
    mapKeyReport.printMessagesTo(messager);

    if (mapKeyReport.isClean()) {
      MapKey mapkey = element.getAnnotation(MapKey.class);
      if (!mapkey.unwrapValue()) {
        try {
          mapKeyGenerator.generate(element);
        } catch (SourceFileGenerationException e) {
          e.printMessageTo(messager);
        }
      }
    }
  }
}
 
Example 2
Source File: ComponentProcessingStep.java    From dagger2-sample with Apache License 2.0 6 votes vote down vote up
@Override
public void process(SetMultimap<Class<? extends Annotation>, Element> elementsByAnnotation) {
  Set<? extends Element> componentElements = elementsByAnnotation.get(Component.class);

  for (Element element : componentElements) {
    TypeElement componentTypeElement = MoreElements.asType(element);
    ValidationReport<TypeElement> componentReport =
        componentValidator.validate(componentTypeElement);
    componentReport.printMessagesTo(messager);
    if (componentReport.isClean()) {
      ComponentDescriptor componentDescriptor =
          componentDescriptorFactory.forComponent(componentTypeElement);
      BindingGraph bindingGraph = bindingGraphFactory.create(componentDescriptor);
      ValidationReport<BindingGraph> graphReport =
          bindingGraphValidator.validate(bindingGraph);
      graphReport.printMessagesTo(messager);
      if (graphReport.isClean()) {
        try {
          componentGenerator.generate(bindingGraph);
        } catch (SourceFileGenerationException e) {
          e.printMessageTo(messager);
        }
      }
    }
  }
}
 
Example 3
Source File: IpsecUtil.java    From batfish with Apache License 2.0 6 votes vote down vote up
/**
 * Returns all {@link IpsecPeerConfigId}s whose local IP is equal to any of the IPs behind
 * destinationIp after NAT
 */
@Nonnull
private static Set<IpsecPeerConfigId> getCandidatePeersBehindNat(
    @Nonnull Ip destinationIp,
    @Nonnull SetMultimap<Ip, IpWildcardSetIpSpace> privateIpsByPublicIp,
    @Nonnull Map<Ip, Set<IpsecPeerConfigId>> localIpsAndIpsecPeers) {
  ImmutableSet.Builder<IpsecPeerConfigId> candidateNeighbors = ImmutableSet.builder();
  Set<IpWildcardSetIpSpace> privateIpsBehindDestIp = privateIpsByPublicIp.get(destinationIp);
  if (privateIpsBehindDestIp == null) {
    return candidateNeighbors.build();
  }
  for (IpWildcardSetIpSpace ipWildcardSetIpSpace : privateIpsBehindDestIp) {
    for (Entry<Ip, Set<IpsecPeerConfigId>> entry : localIpsAndIpsecPeers.entrySet()) {
      if (ipWildcardSetIpSpace.containsIp(entry.getKey(), ImmutableMap.of())) {
        candidateNeighbors.addAll(entry.getValue());
      }
    }
  }
  return candidateNeighbors.build();
}
 
Example 4
Source File: FusingAndroidManifestMerger.java    From bundletool with Apache License 2.0 6 votes vote down vote up
private static ImmutableMap<BundleModuleName, AndroidManifest> ensureOneManifestPerModule(
    SetMultimap<BundleModuleName, AndroidManifest> manifests) {
  ImmutableMap.Builder<BundleModuleName, AndroidManifest> builder = ImmutableMap.builder();
  for (BundleModuleName moduleName : manifests.keys()) {
    Set<AndroidManifest> moduleManifests = manifests.get(moduleName);
    if (moduleManifests.size() != 1) {
      throw CommandExecutionException.builder()
          .withInternalMessage(
              "Expected exactly one %s module manifest, but found %d.",
              moduleName.getName(), moduleManifests.size())
          .build();
    }
    builder.put(moduleName, Iterables.getOnlyElement(moduleManifests));
  }
  return builder.build();
}
 
Example 5
Source File: ProductionComponentProcessingStep.java    From dagger2-sample with Apache License 2.0 6 votes vote down vote up
@Override
public void process(SetMultimap<Class<? extends Annotation>, Element> elementsByAnnotation) {
  Set<? extends Element> componentElements = elementsByAnnotation.get(ProductionComponent.class);

  for (Element element : componentElements) {
    TypeElement componentTypeElement = MoreElements.asType(element);
    ValidationReport<TypeElement> componentReport =
        componentValidator.validate(componentTypeElement);
    componentReport.printMessagesTo(messager);
    if (componentReport.isClean()) {
      ComponentDescriptor componentDescriptor =
          componentDescriptorFactory.forProductionComponent(componentTypeElement);
      BindingGraph bindingGraph = bindingGraphFactory.create(componentDescriptor);
      ValidationReport<BindingGraph> graphReport =
          bindingGraphValidator.validate(bindingGraph);
      graphReport.printMessagesTo(messager);
      if (graphReport.isClean()) {
        try {
          componentGenerator.generate(bindingGraph);
        } catch (SourceFileGenerationException e) {
          e.printMessageTo(messager);
        }
      }
    }
  }
}
 
Example 6
Source File: DataBundleLogic.java    From teammates with GNU General Public License v2.0 5 votes vote down vote up
private void processSessionsAndUpdateRespondents(Collection<FeedbackSessionAttributes> sessions,
        SetMultimap<String, InstructorAttributes> courseInstructorsMap,
        SetMultimap<String, FeedbackQuestionAttributes> sessionQuestionsMap,
        SetMultimap<String, FeedbackResponseAttributes> sessionResponsesMap) {
    for (FeedbackSessionAttributes session : sessions) {
        String sessionKey = makeSessionKey(session.getFeedbackSessionName(), session.getCourseId());

        Set<InstructorAttributes> courseInstructors = courseInstructorsMap.get(session.getCourseId());
        Set<FeedbackQuestionAttributes> sessionQuestions = sessionQuestionsMap.get(sessionKey);
        Set<FeedbackResponseAttributes> sessionResponses = sessionResponsesMap.get(sessionKey);

        updateRespondents(session, courseInstructors, sessionQuestions, sessionResponses);
    }
}
 
Example 7
Source File: AdapterProcessingStep.java    From paperparcel with Apache License 2.0 5 votes vote down vote up
@Override public Set<Element> process(
    SetMultimap<Class<? extends Annotation>, Element> elementsByAnnotation) {
  Set<Element> processorConfigElements = elementsByAnnotation.get(ProcessorConfig.class);
  if (processorConfigElements.size() > 1) {
    messager.printMessage(Diagnostic.Kind.ERROR, ErrorMessages.MULTIPLE_PROCESSOR_CONFIGS);
  } else if (processorConfigElements.size() == 1) {
    Element configElement = processorConfigElements.iterator().next();
    AnnotationMirror config = getAnnotationMirror(configElement, ProcessorConfig.class).get();
    ImmutableList<AnnotationMirror> adapterMirrors = getAnnotationValue(config, "adapters")
        .accept(ANNOTATION_ARRAY_VISITOR, null);
    for (AnnotationMirror adapterMirror : adapterMirrors) {
      TypeElement adapterElement = asType(asDeclared(getAnnotationValue(adapterMirror, "value")
          .accept(Utils.TO_TYPE, null))
          .asElement());
      if (!adapterRegistry.contains(adapterElement)) {
        ValidationReport<TypeElement> report = adapterValidator.validate(adapterElement);
        report.printMessagesTo(messager);
        if (report.isClean()) {
          boolean nullSafe = getAnnotationValue(adapterMirror, "nullSafe")
              .accept(Utils.TO_BOOLEAN, null);
          adapterRegistry.addClassEntry(adapterElement, nullSafe);
        }
      }
    }
  }
  return ImmutableSet.of();
}
 
Example 8
Source File: OptionsProcessingStep.java    From paperparcel with Apache License 2.0 5 votes vote down vote up
@Override public Set<Element> process(
    SetMultimap<Class<? extends Annotation>, Element> elementsByAnnotation) {
  Set<Element> processorConfigElements = elementsByAnnotation.get(ProcessorConfig.class);
  if (optionsHolder.isOptionsApplied() || processorConfigElements.size() > 1) {
    messager.printMessage(Diagnostic.Kind.ERROR, ErrorMessages.MULTIPLE_PROCESSOR_CONFIGS);
  } else if (processorConfigElements.size() == 1) {
    Element configElement = processorConfigElements.iterator().next();
    AnnotationMirror config = getAnnotationMirror(configElement, ProcessorConfig.class).get();
    optionsHolder.setOptions(Utils.getModuleOptions(config));
  }
  return ImmutableSet.of();
}
 
Example 9
Source File: BaggageImpl.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Get all values from the baggage for a given namespace and key
 * 
 * @param namespace The namespace the key resides in
 * @param key The key to look up within the provided namespace
 * @return The set of all values mapped to that key */
public Set<ByteString> get(ByteString namespace, ByteString key) {
    if (namespace != null || key != null) {
        SetMultimap<ByteString, ByteString> namespaceData = contents.get(namespace);
        if (namespaceData != null) {
            return namespaceData.get(key);
        }
    }
    return Collections.<ByteString> emptySet(); 
}
 
Example 10
Source File: WriteFanoutEventPersistor.java    From tasmo with Apache License 2.0 5 votes vote down vote up
@Override
public void removeValueFields(VersionedTasmoViewModel model, String className, TenantIdAndCentricId tenantIdAndCentricId, ObjectId instanceId,
    long timestamp) {
    concurrencyStore.removeObjectId(Arrays.asList(new ExistenceUpdate(tenantIdAndCentricId, timestamp, instanceId)));

    SetMultimap<String, TasmoViewModel.FieldNameAndType> eventModel = model.getEventModel();
    Set<String> fieldNames = new HashSet<>();
    for (TasmoViewModel.FieldNameAndType fieldNameAndType : eventModel.get(className)) {
        if (fieldNameAndType.getFieldType() == ModelPathStepType.value) {
            String fieldName = fieldNameAndType.getFieldName();
            fieldNames.add(fieldName);
        }
    }
    eventValueStore.removeObjectId(tenantIdAndCentricId, timestamp, instanceId, fieldNames.toArray(new String[fieldNames.size()]));
}
 
Example 11
Source File: AbstractAnchor.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private void updatePositions(Node anchored) {
	SetMultimap<Node, AnchorKey> keys = getKeysByNode();
	if (keys.containsKey(anchored)) {
		Set<AnchorKey> keysCopy = new HashSet<>(keys.get(anchored));
		for (AnchorKey key : keysCopy) {
			updatePosition(key);
		}
	}
}
 
Example 12
Source File: AptThatWritesNativeJsFile.java    From j2cl with Apache License 2.0 5 votes vote down vote up
@Override
public Set<Element> process(
    SetMultimap<Class<? extends Annotation>, Element> elementsByAnnotation) {
  for (Element value : elementsByAnnotation.get(RunApt.class)) {
    TypeElement typeElement = MoreElements.asType(value);
    String packageName = MoreElements.getPackage(typeElement).getQualifiedName().toString();
    writeNativeJsFile(packageName, typeElement.getSimpleName().toString());
  }
  writeJsFile("com.google.j2cl.transpiler.integration.nativeinjectionapt", "NativeClass");
  return ImmutableSet.of();
}
 
Example 13
Source File: DataBundleLogic.java    From teammates with GNU General Public License v2.0 5 votes vote down vote up
private void updateRespondents(FeedbackSessionAttributes session,
        Set<InstructorAttributes> courseInstructors,
        Set<FeedbackQuestionAttributes> sessionQuestions,
        Set<FeedbackResponseAttributes> sessionResponses) {
    String sessionKey = makeSessionKey(session.getFeedbackSessionName(), session.getCourseId());

    SetMultimap<String, String> instructorQuestionKeysMap = HashMultimap.create();
    for (InstructorAttributes instructor : courseInstructors) {
        List<FeedbackQuestionAttributes> questionsForInstructor =
                fqLogic.getFeedbackQuestionsForInstructor(
                        new ArrayList<>(sessionQuestions), session.isCreator(instructor.email));

        List<String> questionKeys = makeQuestionKeys(questionsForInstructor, sessionKey);
        instructorQuestionKeysMap.putAll(instructor.email, questionKeys);
    }

    Set<String> respondingInstructors = new HashSet<>();
    Set<String> respondingStudents = new HashSet<>();

    for (FeedbackResponseAttributes response : sessionResponses) {
        String respondent = response.giver;
        String responseQuestionNumber = response.feedbackQuestionId; // contains question number before injection
        String responseQuestionKey = makeQuestionKey(sessionKey, responseQuestionNumber);

        Set<String> instructorQuestionKeys = instructorQuestionKeysMap.get(respondent);
        if (instructorQuestionKeys.contains(responseQuestionKey)) {
            respondingInstructors.add(respondent);
        } else {
            respondingStudents.add(respondent);
        }
    }

    session.setRespondingInstructorList(respondingInstructors);
    session.setRespondingStudentList(respondingStudents);
}
 
Example 14
Source File: WriteFanoutEventPersistor.java    From tasmo with Apache License 2.0 5 votes vote down vote up
@Override
public void removeValueFields(VersionedTasmoViewModel model, String className, TenantIdAndCentricId tenantIdAndCentricId, ObjectId instanceId,
    long timestamp) {
    concurrencyStore.removeObjectId(Arrays.asList(new ExistenceUpdate(tenantIdAndCentricId, timestamp, instanceId)));

    SetMultimap<String, TasmoViewModel.FieldNameAndType> eventModel = model.getEventModel();
    Set<String> fieldNames = new HashSet<>();
    for (TasmoViewModel.FieldNameAndType fieldNameAndType : eventModel.get(className)) {
        if (fieldNameAndType.getFieldType() == ModelPathStepType.value) {
            String fieldName = fieldNameAndType.getFieldName();
            fieldNames.add(fieldName);
        }
    }
    eventValueStore.removeObjectId(tenantIdAndCentricId, timestamp, instanceId, fieldNames.toArray(new String[fieldNames.size()]));
}
 
Example 15
Source File: EntityListenersService.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Update all registered listeners of an entity */
void updateEntity(String repoFullName, Entity entity) {
  lock.readLock().lock();
  try {
    verifyRepoRegistered(repoFullName);
    SetMultimap<Object, EntityListener> entityListeners =
        this.entityListenersByRepo.get(repoFullName);
    Set<EntityListener> entityEntityListeners = entityListeners.get(entity.getIdValue());
    entityEntityListeners.forEach(entityListener -> entityListener.postUpdate(entity));
  } finally {
    lock.readLock().unlock();
  }
}
 
Example 16
Source File: AliasConfig.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * In a {@link BuckConfig}, an alias can either refer to a fully-qualified build target, or an
 * alias defined earlier in the {@code alias} section. The mapping produced by this method
 * reflects the result of resolving all aliases as values in the {@code alias} section.
 */
private ImmutableSetMultimap<String, UnconfiguredBuildTarget> createAliasToBuildTargetMap(
    ImmutableMap<String, String> rawAliasMap) {
  // We use a LinkedHashMap rather than an ImmutableMap.Builder because we want both (1) order to
  // be preserved, and (2) the ability to inspect the Map while building it up.
  SetMultimap<String, UnconfiguredBuildTarget> aliasToBuildTarget = LinkedHashMultimap.create();
  for (Map.Entry<String, String> aliasEntry : rawAliasMap.entrySet()) {
    String alias = aliasEntry.getKey();
    validateAliasName(alias);

    // Determine whether the mapping is to a build target or to an alias.
    List<String> values = Splitter.on(' ').splitToList(aliasEntry.getValue());
    for (String value : values) {
      Set<UnconfiguredBuildTarget> buildTargets;
      if (isValidAliasName(value)) {
        buildTargets = aliasToBuildTarget.get(value);
        if (buildTargets.isEmpty()) {
          throw new HumanReadableException("No alias for: %s.", value);
        }
      } else if (value.isEmpty()) {
        continue;
      } else {
        // Here we parse the alias values with a BuildTargetParser to be strict. We could be
        // looser and just grab everything between "//" and ":" and assume it's a valid base path.
        buildTargets =
            ImmutableSet.of(
                getDelegate().getUnconfiguredBuildTargetForFullyQualifiedTarget(value));
      }
      aliasToBuildTarget.putAll(alias, buildTargets);
    }
  }
  return ImmutableSetMultimap.copyOf(aliasToBuildTarget);
}
 
Example 17
Source File: SetMultimapExpression.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Set<V> get(K key) {
	final SetMultimap<K, V> setMultimap = get();
	return (setMultimap == null) ? EMPTY_SETMULTIMAP.get(key)
			: setMultimap.get(key);
}
 
Example 18
Source File: NullAway.java    From NullAway with MIT License 4 votes vote down vote up
/**
 * check that all @NonNull fields of the class are properly initialized
 *
 * @param tree the class
 * @param state visitor state
 */
private void checkFieldInitialization(ClassTree tree, VisitorState state) {
  FieldInitEntities entities = collectEntities(tree, state);
  Symbol.ClassSymbol classSymbol = ASTHelpers.getSymbol(tree);
  class2Entities.put(classSymbol, entities);
  // set of all non-null instance fields f such that *some* constructor does not initialize f
  Set<Symbol> notInitializedInConstructors;
  SetMultimap<MethodTree, Symbol> constructorInitInfo;
  if (entities.constructors().isEmpty()) {
    constructorInitInfo = null;
    notInitializedInConstructors = entities.nonnullInstanceFields();
  } else {
    constructorInitInfo = checkConstructorInitialization(entities, state);
    notInitializedInConstructors = ImmutableSet.copyOf(constructorInitInfo.values());
  }
  class2ConstructorUninit.putAll(classSymbol, notInitializedInConstructors);
  Set<Symbol> notInitializedAtAll =
      notAssignedInAnyInitializer(entities, notInitializedInConstructors, state);
  SetMultimap<Element, Element> errorFieldsForInitializer = LinkedHashMultimap.create();
  // non-null if we have a single initializer method
  Symbol.MethodSymbol singleInitializerMethod = null;
  if (entities.instanceInitializerMethods().size() == 1) {
    singleInitializerMethod =
        ASTHelpers.getSymbol(entities.instanceInitializerMethods().iterator().next());
  }
  for (Symbol uninitField : notInitializedAtAll) {
    if (errorBuilder.symbolHasSuppressWarningsAnnotation(
        uninitField, INITIALIZATION_CHECK_NAME)) {
      continue;
    }
    if (singleInitializerMethod != null) {
      // report it on the initializer
      errorFieldsForInitializer.put(singleInitializerMethod, uninitField);
    } else if (constructorInitInfo == null) {
      // report it on the field, except in the case where the class is externalInit and
      // we have no initializer methods
      if (!(isExternalInit(classSymbol) && entities.instanceInitializerMethods().isEmpty())) {
        errorBuilder.reportInitErrorOnField(
            uninitField, state, buildDescription(getTreesInstance(state).getTree(uninitField)));
      }
    } else {
      // report it on each constructor that does not initialize it
      for (MethodTree methodTree : constructorInitInfo.keySet()) {
        Set<Symbol> uninitFieldsForConstructor = constructorInitInfo.get(methodTree);
        if (uninitFieldsForConstructor.contains(uninitField)) {
          errorFieldsForInitializer.put(ASTHelpers.getSymbol(methodTree), uninitField);
        }
      }
    }
  }
  for (Element constructorElement : errorFieldsForInitializer.keySet()) {
    errorBuilder.reportInitializerError(
        (Symbol.MethodSymbol) constructorElement,
        errMsgForInitializer(errorFieldsForInitializer.get(constructorElement), state),
        state,
        buildDescription(getTreesInstance(state).getTree(constructorElement)));
  }
  // For static fields
  Set<Symbol> notInitializedStaticFields = notInitializedStatic(entities, state);
  for (Symbol uninitSField : notInitializedStaticFields) {
    // Always report it on the field for static fields (can't do @SuppressWarnings on a static
    // initialization block
    // anyways).
    errorBuilder.reportInitErrorOnField(
        uninitSField, state, buildDescription(getTreesInstance(state).getTree(uninitSField)));
  }
}
 
Example 19
Source File: LocalExecutionPlanner.java    From presto with Apache License 2.0 4 votes vote down vote up
@Override
public PhysicalOperation visitIndexSource(IndexSourceNode node, LocalExecutionPlanContext context)
{
    checkState(context.getIndexSourceContext().isPresent(), "Must be in an index source context");
    IndexSourceContext indexSourceContext = context.getIndexSourceContext().get();

    SetMultimap<Symbol, Integer> indexLookupToProbeInput = indexSourceContext.getIndexLookupToProbeInput();
    checkState(indexLookupToProbeInput.keySet().equals(node.getLookupSymbols()));

    // Finalize the symbol lookup layout for the index source
    List<Symbol> lookupSymbolSchema = ImmutableList.copyOf(node.getLookupSymbols());

    // Identify how to remap the probe key Input to match the source index lookup layout
    ImmutableList.Builder<Integer> remappedProbeKeyChannelsBuilder = ImmutableList.builder();
    // Identify overlapping fields that can produce the same lookup symbol.
    // We will filter incoming keys to ensure that overlapping fields will have the same value.
    ImmutableList.Builder<Set<Integer>> overlappingFieldSetsBuilder = ImmutableList.builder();
    for (Symbol lookupSymbol : lookupSymbolSchema) {
        Set<Integer> potentialProbeInputs = indexLookupToProbeInput.get(lookupSymbol);
        checkState(!potentialProbeInputs.isEmpty(), "Must have at least one source from the probe input");
        if (potentialProbeInputs.size() > 1) {
            overlappingFieldSetsBuilder.add(potentialProbeInputs.stream().collect(toImmutableSet()));
        }
        remappedProbeKeyChannelsBuilder.add(Iterables.getFirst(potentialProbeInputs, null));
    }
    List<Set<Integer>> overlappingFieldSets = overlappingFieldSetsBuilder.build();
    List<Integer> remappedProbeKeyChannels = remappedProbeKeyChannelsBuilder.build();
    Function<RecordSet, RecordSet> probeKeyNormalizer = recordSet -> {
        if (!overlappingFieldSets.isEmpty()) {
            recordSet = new FieldSetFilteringRecordSet(metadata, recordSet, overlappingFieldSets);
        }
        return new MappedRecordSet(recordSet, remappedProbeKeyChannels);
    };

    // Declare the input and output schemas for the index and acquire the actual Index
    List<ColumnHandle> lookupSchema = Lists.transform(lookupSymbolSchema, forMap(node.getAssignments()));
    List<ColumnHandle> outputSchema = Lists.transform(node.getOutputSymbols(), forMap(node.getAssignments()));
    ConnectorIndex index = indexManager.getIndex(session, node.getIndexHandle(), lookupSchema, outputSchema);

    OperatorFactory operatorFactory = new IndexSourceOperator.IndexSourceOperatorFactory(context.getNextOperatorId(), node.getId(), index, probeKeyNormalizer);
    return new PhysicalOperation(operatorFactory, makeLayout(node), context, UNGROUPED_EXECUTION);
}
 
Example 20
Source File: ProducerModuleProcessingStep.java    From dagger2-sample with Apache License 2.0 4 votes vote down vote up
@Override
public void process(SetMultimap<Class<? extends Annotation>, Element> elementsByAnnotation) {
  // first, check and collect all produces methods
  ImmutableSet.Builder<ExecutableElement> validProducesMethodsBuilder = ImmutableSet.builder();
  for (Element producesElement : elementsByAnnotation.get(Produces.class)) {
    if (producesElement.getKind().equals(METHOD)) {
      ExecutableElement producesMethodElement = (ExecutableElement) producesElement;
      ValidationReport<ExecutableElement> methodReport =
          producesMethodValidator.validate(producesMethodElement);
      methodReport.printMessagesTo(messager);
      if (methodReport.isClean()) {
        validProducesMethodsBuilder.add(producesMethodElement);
      }
    }
  }
  ImmutableSet<ExecutableElement> validProducesMethods = validProducesMethodsBuilder.build();

  // process each module
  for (Element moduleElement :
      Sets.difference(elementsByAnnotation.get(ProducerModule.class),
          processedModuleElements)) {
    if (SuperficialValidation.validateElement(moduleElement)) {
      ValidationReport<TypeElement> report =
          moduleValidator.validate(MoreElements.asType(moduleElement));
      report.printMessagesTo(messager);

      if (report.isClean()) {
        ImmutableSet.Builder<ExecutableElement> moduleProducesMethodsBuilder =
            ImmutableSet.builder();
        List<ExecutableElement> moduleMethods =
            ElementFilter.methodsIn(moduleElement.getEnclosedElements());
        for (ExecutableElement methodElement : moduleMethods) {
          if (isAnnotationPresent(methodElement, Produces.class)) {
            moduleProducesMethodsBuilder.add(methodElement);
          }
        }
        ImmutableSet<ExecutableElement> moduleProducesMethods =
            moduleProducesMethodsBuilder.build();

        if (Sets.difference(moduleProducesMethods, validProducesMethods).isEmpty()) {
          // all of the produces methods in this module are valid!
          // time to generate some factories!
          ImmutableSet<ProductionBinding> bindings = FluentIterable.from(moduleProducesMethods)
              .transform(new Function<ExecutableElement, ProductionBinding>() {
                @Override
                public ProductionBinding apply(ExecutableElement producesMethod) {
                  return productionBindingFactory.forProducesMethod(producesMethod,
                      producesMethod.getEnclosingElement().asType());
                }
              })
              .toSet();

          try {
            for (ProductionBinding binding : bindings) {
              factoryGenerator.generate(binding);
            }
          } catch (SourceFileGenerationException e) {
            e.printMessageTo(messager);
          }
        }
      }

      processedModuleElements.add(moduleElement);
    }
  }
}