@Override public GeneratorRepository get() { GeneratorRepository repository = new GeneratorRepository(); repository.add( astMatcherBuilder.type().annotatedWith(Injector.class).build(), injectorGenerator); repository.add( astMatcherBuilder.type().annotatedWith(Activity.class).build(), analysisGenerationFactory.buildAnalysisGeneration(activityAnalysis, componentGenerator)); repository.add( astMatcherBuilder.type().annotatedWith(BroadcastReceiver.class).build(), analysisGenerationFactory.buildAnalysisGeneration( broadcastReceiverAnalysis, componentGenerator)); repository.add( astMatcherBuilder.type().annotatedWith(Service.class).build(), analysisGenerationFactory.buildAnalysisGeneration(serviceAnalysis, componentGenerator)); repository.add( astMatcherBuilder.type().annotatedWith(Fragment.class).build(), analysisGenerationFactory.buildAnalysisGeneration(fragmentAnalysis, componentGenerator)); return repository; }
@Override public GeneratorRepository get() { ImmutableMap.Builder< Class<? extends Annotation>, TransactionProcessorBuilder<Provider<ASTType>, ?>> processorMapBuilder = ImmutableMap.builder(); ImmutableSet.Builder<TransactionProcessor<Provider<ASTType>, JDefinedClass>> componentProcessors = ImmutableSet.builder(); // Module and ImplementedBy configuration processing processorMapBuilder.put(TransfuseModule.class, moduleProcessorBuilder); processorMapBuilder.put(ImplementedBy.class, implementedByProcessorBuilder); TransactionProcessor<Provider<ASTType>, Void> configurationProcessors = new TransactionProcessorComposite<Provider<ASTType>, Void>( ImmutableSet.of( moduleProcessorBuilder.getTransactionProcessor(), implementedByProcessorBuilder.getTransactionProcessor())); // Component processing Map<Class<? extends Annotation>, Provider<? extends Analysis<ComponentDescriptor>>> analyzers = new HashMap< Class<? extends Annotation>, Provider<? extends Analysis<ComponentDescriptor>>>(); analyzers.put(Application.class, applicationAnalysisProvider); analyzers.put(Activity.class, activityAnalysisProvider); analyzers.put(BroadcastReceiver.class, broadcastReceiverAnalysisProvider); analyzers.put(Service.class, serviceAnalysisProvider); analyzers.put(Fragment.class, fragmentAnalysisProvider); for (Map.Entry<Class<? extends Annotation>, Provider<? extends Analysis<ComponentDescriptor>>> providerEntry : analyzers.entrySet()) { Provider<TransactionWorker<Provider<ASTType>, JDefinedClass>> workerProvider = analysisGenerationFactory.buildAnalysisGenerationProvider(providerEntry.getValue()); AnalysisGenerationTransactionProcessorBuilder processorBuilder = processorFactory.buildBuilder(workerProvider); componentProcessors.add(processorBuilder.getTransactionProcessor()); processorMapBuilder.put(providerEntry.getKey(), processorBuilder); } TransactionProcessor<Provider<ASTType>, JDefinedClass> componentsProcessor = new TransactionProcessorComposite<Provider<ASTType>, JDefinedClass>( componentProcessors.build()); // Manifest processing (depends on components) TransactionProcessor<Void, Void> manifestProcessor = new TransactionProcessorPredefined( ImmutableSet.of(new Transaction<Void, Void>(generateModuleProcessor))); TransactionProcessor<Void, Void> componentProcessorCompletion = new TransactionProcessorChain( new TransactionProcessorChannel<Provider<ASTType>, JDefinedClass, Void>( componentsProcessor, componentsRepositoryProcessor, componentsTransactionFactory), manifestProcessor); ImmutableSet.Builder<TransactionProcessor<?, ?>> configurationDependentBuilders = ImmutableSet.builder(); configurationDependentBuilders.add(factoryProcessor.getTransactionProcessor()); configurationDependentBuilders.add(componentProcessorCompletion); processorMapBuilder.put(Factory.class, factoryProcessor); // Package Helper processing (to be run last) TransactionProcessor<Void, Void> packageHelperProcessor = new TransactionProcessorPredefined( ImmutableSet.of( packageHelperTransactionFactory.buildTransaction(), virtualProxyTransactionFactory.buildTransaction(), scopesUtilityTransactionFactory.buildTransaction())); TransactionProcessor<?, ?> configurationDependentProcessors = new TransactionProcessorComposite(configurationDependentBuilders.build()); TransactionProcessor<Void, Void> processor = new TransactionProcessorChain( configurationProcessors, new TransactionProcessorChain( configurationDependentProcessors, packageHelperProcessor)); return new GeneratorRepository(processorMapBuilder.build(), processor); }