All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.inject.internal.AbstractProcessor Maven / Gradle / Ivy

package com.google.inject.internal;

import com.google.inject.spi.DefaultElementVisitor;
import com.google.inject.spi.Element;

import java.util.Iterator;
import java.util.List;

/**
 * Abstract base class for creating an injector from module elements.
 *
 * 

Extending classes must return {@code true} from any overridden * {@code visit*()} methods, in order for the element processor to remove the * handled element. * */ abstract class AbstractProcessor extends DefaultElementVisitor { protected Errors errors; protected InjectorImpl injector; protected AbstractProcessor(Errors errors) { this.errors = errors; } public void process(Iterable isolatedInjectorBuilders) { for (InjectorShell injectorShell : isolatedInjectorBuilders) { process(injectorShell.getInjector(), injectorShell.getElements()); } } public void process(InjectorImpl injector, List elements) { Errors errorsAnyElement = this.errors; this.injector = injector; try { for (Iterator i = elements.iterator(); i.hasNext(); ) { Element element = i.next(); this.errors = errorsAnyElement.withSource(element.getSource()); Boolean allDone = element.acceptVisitor(this); if (allDone) { i.remove(); } } } finally { this.errors = errorsAnyElement; this.injector = null; } } @Override protected Boolean visitOther(Element element) { return false; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy