Interface InstanceFactory<S extends Source>


public interface InstanceFactory<S extends Source>
Functional interface for creating instances of a given class.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    createInstance(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 resolution
      cls - the class to instantiate
      Returns:
      a new instance of the specified class
      Throws:
      UnknownDependencyException
    • defaultFactory

      static <S extends Source> InstanceFactory<S> 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