Class Injector<T extends java.lang.annotation.Annotation>

  • Type Parameters:
    T - the annotation type

    public class Injector<T extends java.lang.annotation.Annotation>
    extends java.lang.Object
    This class is a simple injector with a parameterized annotation. A domain function is provided to retrieve the values.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Injector.Target<T>
      The Target class describes the target injection point.
    • Constructor Summary

      Constructors 
      Constructor Description
      Injector​(Converter converter, java.util.function.Function<Injector.Target<T>,​java.lang.Object> domain, java.lang.Class<T> annotation)
      Create a new Injector
      Injector​(java.util.function.Function<Injector.Target<T>,​java.lang.Object> domain, java.lang.Class<T> annotation)
      Create a new Injector with a default converter
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void inject​(java.lang.Object target)
      Inject an object.
      <F> F newInstance​(java.lang.Class<F> type)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Injector

        public Injector​(Converter converter,
                        java.util.function.Function<Injector.Target<T>,​java.lang.Object> domain,
                        java.lang.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​(java.util.function.Function<Injector.Target<T>,​java.lang.Object> domain,
                        java.lang.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 Detail

      • inject

        public void inject​(java.lang.Object target)
                    throws java.lang.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:
        java.lang.Exception
      • newInstance

        public <F> F newInstance​(java.lang.Class<F> type)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception