Interface Injector<I extends Injector<I,B>, B extends InjectorBuilder<B,I>>

Type Parameters:
I - This type
B - The associated InjectorBuilder type
All Known Implementing Classes:
ReflectionInjector

public interface Injector<I extends Injector<I,B>, B extends InjectorBuilder<B,I>>
An injector capable of injecting fields, methods, and constructors
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    create(Class<T> cls)
    Creates a new instance of the given class by attempting to inject into a constructor
    default <T> T
    Creates a new instance of the given class by attempting to inject into a constructor, then injects the instance's fields and methods
    void
    inject(Object object)
    Attempts to inject the appropriate fields, and call the appropriate injection methods, on the given object
    void
    Attempts to inject the appropriate static fields, and call the appropriate static injection methods, on the given object
    Copies this Injector's settings into a builder of the appropriate type, and returns it.
  • Method Details

    • toBuilder

      B toBuilder()
      Copies this Injector's settings into a builder of the appropriate type, and returns it.
      Returns:
      A new builder with this Injector's settings
    • createAndInject

      default <T> T createAndInject(Class<T> cls)
      Creates a new instance of the given class by attempting to inject into a constructor, then injects the instance's fields and methods
      Type Parameters:
      T - The type of the class
      Parameters:
      cls - The cls to instantiate
      Returns:
      A new instance of T
    • create

      <T> T create(Class<T> cls)
      Creates a new instance of the given class by attempting to inject into a constructor
      Type Parameters:
      T - The type of the class
      Parameters:
      cls - The class to instantiate
      Returns:
      A new instance of T
    • inject

      void inject(Object object)
      Attempts to inject the appropriate fields, and call the appropriate injection methods, on the given object
      Parameters:
      object - The object to inject into
    • injectStatic

      void injectStatic(Class<?> cls)
      Attempts to inject the appropriate static fields, and call the appropriate static injection methods, on the given object
      Parameters:
      cls - The class to inject into