Class MethodInjector<T>

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

    public final class MethodInjector<T>
    extends java.lang.Object
    implements Injector<T>
    An injector which invokes a method. The value being injected can be specified by Values.injectedValue(). The value being invoked upon can be specified by Values.thisValue().
    • Constructor Summary

      Constructors 
      Constructor Description
      MethodInjector​(java.lang.reflect.Method method, Value<?> targetValue, Value<?> injectedValue, java.util.List<? extends Value<?>> parameterList)
      Construct a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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

      • method

        private final java.lang.reflect.Method method
      • injectedValue

        private final Value<?> injectedValue
      • targetValue

        private final Value<?> targetValue
      • parameterList

        private final java.util.List<? extends Value<?>> parameterList
    • Constructor Detail

      • MethodInjector

        public MethodInjector​(java.lang.reflect.Method method,
                              Value<?> targetValue,
                              Value<?> injectedValue,
                              java.util.List<? extends Value<?>> parameterList)
        Construct a new instance.
        Parameters:
        method - the method to invoke
        targetValue - the value of the invocation target (the object being called upon) - use Values.nullValue() for static methods
        injectedValue - the value to use for Values.injectedValue() on uninjection (usually Values.nullValue())
        parameterList - the list of parameter values (any null parameters should use Values.nullValue())
    • Method Detail

      • 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>