Class FieldInjector<T>

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

    public final class FieldInjector<T>
    extends java.lang.Object
    implements Injector<T>
    An injector which updates the value of a field.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.reflect.Field field  
      private Value<?> target  
    • Constructor Summary

      Constructors 
      Constructor Description
      FieldInjector​(Value<?> target, java.lang.reflect.Field field)
      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).
      private void uninjectPrimitive​(java.lang.reflect.Field field, java.lang.Class<?> fieldType, java.lang.Object targetValue)  
      • Methods inherited from class java.lang.Object

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

      • target

        private final Value<?> target
      • field

        private final java.lang.reflect.Field field
    • Constructor Detail

      • FieldInjector

        public FieldInjector​(Value<?> target,
                             java.lang.reflect.Field field)
        Construct a new instance.
        Parameters:
        target - the object whose field is to be updated
        field - the field to update
    • Method Detail

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

        private void uninjectPrimitive​(java.lang.reflect.Field field,
                                       java.lang.Class<?> fieldType,
                                       java.lang.Object targetValue)
                                throws java.lang.IllegalArgumentException,
                                       java.lang.IllegalAccessException
        Throws:
        java.lang.IllegalArgumentException
        java.lang.IllegalAccessException