Class Injector<T extends Annotation>

java.lang.Object
aQute.lib.inject.Injector<T>
Type Parameters:
T - the annotation type

public class Injector<T extends Annotation> extends Object
This class is a simple injector with a parameterized annotation. A domain function is provided to retrieve the values.
  • Constructor Details

    • Injector

      public Injector(Converter converter, Function<Injector.Target<T>,Object> domain, Class<T> annotation)
      Create a new Injector
      Parameters:
      converter - the converter to use for conversions
      domain - the domain function that retrieves values
      annotation - the annotation that triggers a call to the domain
    • Injector

      public Injector(Function<Injector.Target<T>,Object> domain, Class<T> annotation)
      Create a new Injector with a default converter
      Parameters:
      domain - the domain function that retrieves values
      annotation - the annotation that triggers a call to the domain
  • Method Details

    • inject

      public void inject(Object target) throws Exception
      Inject an object. This will inject fields and methods. Methods must have one or more arguments. The first argument is special and is always passed to the domain function as the primaryType.
      Parameters:
      target - the target object to inject
      Throws:
      Exception
    • newInstance

      public <F> F newInstance(Class<F> type) throws Exception
      Throws:
      Exception