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

io.datakernel.di.impl.PlainCompiler Maven / Gradle / Ivy

Go to download

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 key;

	public PlainCompiler(Key key) {
		this.key = key;
	}

	public Key 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