Interface InstanceFactory<S extends Source>
public interface InstanceFactory<S extends Source>
Functional interface for creating instances of a given class.
-
Method Summary
Modifier and TypeMethodDescription<T> TcreateInstance(ImperatConfig<S> config, Class<T> cls) Creates an instance of the specified class.static <S extends Source>
InstanceFactory<S>Creates a default instance factory that uses the provided ImperatConfig for dependency resolution.
-
Method Details
-
createInstance
@NotNull <T> T createInstance(ImperatConfig<S> config, Class<T> cls) throws UnknownDependencyException Creates an instance of the specified class.- Type Parameters:
T- the type of the instance- Parameters:
config- the config to use for dependency resolutioncls- the class to instantiate- Returns:
- a new instance of the specified class
- Throws:
UnknownDependencyException
-
defaultFactory
Creates a default instance factory that uses the provided ImperatConfig for dependency resolution.- Type Parameters:
S- the type of Source- Returns:
- a default InstanceFactory
-