Class SetMethodInjector<T>

  • Type Parameters:
    T - the value type
    All Implemented Interfaces:
    Injector<T>

    public final class SetMethodInjector<T>
    extends java.lang.Object
    implements Injector<T>
    An injector which calls a setter method.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.reflect.Method method  
      private static java.lang.Object[] NULL_PARAM  
      private Value<?> target  
    • Constructor Summary

      Constructors 
      Constructor Description
      SetMethodInjector​(Value<?> target, java.lang.reflect.Method method)
      Construct a new instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> Injector<T> create​(Value<?> target, java.lang.reflect.Method method)
      Construct a new instance.
      void inject​(T value)
      Inject the given value.
      void uninject()
      Uninject the given value (in other words, cancel or undo a previous injection).
      • Methods inherited from class java.lang.Object

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

      • NULL_PARAM

        private static final java.lang.Object[] NULL_PARAM
      • target

        private final Value<?> target
      • method

        private final java.lang.reflect.Method method
    • Constructor Detail

      • SetMethodInjector

        public SetMethodInjector​(Value<?> target,
                                 java.lang.reflect.Method method)
        Construct a new instance.
        Parameters:
        target - the object upon which the method is to be called
        method - the method to invoke
    • Method Detail

      • create

        public static <T> Injector<T> create​(Value<?> target,
                                             java.lang.reflect.Method method)
        Construct a new instance.
        Parameters:
        target - the object upon which the method is to be called
        method - the method to invoke
        Returns:
        the new instance
      • inject

        public void inject​(T value)
        Inject the given value.
        Specified by:
        inject in interface Injector<T>
        Parameters:
        value - the value
      • uninject

        public void uninject()
        Uninject the given value (in other words, cancel or undo a previous injection). Only called after inject() has been called.
        Specified by:
        uninject in interface Injector<T>