io.github.amayaframework.di.ManualCheckedProviderBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of amaya-di Show documentation
Show all versions of amaya-di Show documentation
A framework responsible for monitoring and automating the dependency injection process.
package io.github.amayaframework.di;
import com.github.romanqed.jfunc.Function0;
import com.github.romanqed.jfunc.Function1;
import io.github.amayaframework.di.scheme.ClassScheme;
import io.github.amayaframework.di.scheme.SchemeFactory;
import io.github.amayaframework.di.stub.StubFactory;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* A {@link ManualProviderBuilder} implementation based on {@link CheckedProviderBuilder}.
*/
public class ManualCheckedProviderBuilder extends CheckedProviderBuilder implements ManualProviderBuilder {
protected Map>> manual;
/**
* Constructs {@link ManualCheckedProviderBuilder} instance with the specified scheme and stub factories.
*
* @param schemeFactory the specified scheme factory, must be non-null
* @param stubFactory the specified stub factory, must be non-null
*/
public ManualCheckedProviderBuilder(SchemeFactory schemeFactory, StubFactory stubFactory) {
super(schemeFactory, stubFactory);
}
@Override
protected void reset() {
super.reset();
this.manual = new HashMap<>();
}
@Override
protected boolean resolve(Artifact artifact) {
return manual.containsKey(artifact) || super.resolve(artifact);
}
@Override
@SuppressWarnings("unchecked")
protected void buildArtifacts(Map, ClassScheme> schemes, LazyProvider provider) {
super.buildArtifacts(schemes, provider);
for (var entry : manual.entrySet()) {
var artifact = entry.getKey();
var builder = entry.getValue();
provider.add(artifact, () -> (Function0
© 2015 - 2025 Weber Informatics LLC | Privacy Policy