io.datakernel.di.impl.PlainCompiler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datakernel-di Show documentation
Show all versions of datakernel-di Show documentation
DataKernel has an extremely lightweight DI with ground-breaking design principles.
It supports nested scopes, singletons, object factories, modules and plugins which
allow to transform graph of dependencies at startup time without any reflection.
The newest version!
package io.datakernel.di.impl;
import io.datakernel.di.core.Binding;
import io.datakernel.di.core.Key;
import org.jetbrains.annotations.Nullable;
/**
* Only reason for this not to be an anonymous class as any other in {@link Binding}
* is that Injector does not allocate a slot for this binding
* despite the binding being cached (so that wrappers such as mapInstance are not non-cached
* as it would've been if the plain binding was make non-cached)
*/
public final class PlainCompiler implements BindingCompiler {
private final Key extends T> key;
public PlainCompiler(Key extends T> key) {
this.key = key;
}
public Key extends T> getKey() {
return key;
}
@SuppressWarnings("unchecked")
@Override
public CompiledBinding compile(CompiledBindingLocator compiledBindings, boolean threadsafe, int scope, @Nullable Integer slot) {
return (CompiledBinding) compiledBindings.get(key);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy