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

de.leanovate.pragmatic.ioc.Injectors Maven / Gradle / Ivy

The newest version!
package de.leanovate.pragmatic.ioc;

import java.util.Optional;
import java.util.function.Supplier;

/**
 * Collection of commonly used {@link de.leanovate.pragmatic.ioc.Injector}s.
 */
public class Injectors {
    /**
     * Create a singleton injector for a type.
     *
     * @param injectedClass the type to be injected
     * @param supplier the supplier of the singleton instance (in production is is only invoked once)
     * @param  the type to be injected
     * @return singleton injector for {@code T}
     */
    public static  Injector singleton(final Class injectedClass, final Supplier supplier) {

        return new ScopedInjector<>(injectedClass, Optional.empty(), Scopes::getSingletonScope, supplier);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy