Class InjectionTarget


  • public class InjectionTarget
    extends Object
    Applies an Injection to a target field.
    Since:
    3.3
    Author:
    Henri Tremblay, Alistair Todd
    • Constructor Detail

      • InjectionTarget

        public InjectionTarget​(Field f)
        Create instance for injection to the given field.
        Parameters:
        f - Field that will receive the Injection
    • Method Detail

      • accepts

        public boolean accepts​(Injection injection)
        Can the given Injection be applied to this InjectionTarget?
        Parameters:
        injection - candidate Injection
        Returns:
        true if injection represents a mock that can be applied to this InjectionTarget, false if the mock is of a type that cannot be assigned
      • inject

        public void inject​(Object obj,
                           Injection injection)
        Perform the injection against the given object set the "matched" status of the injection when successful.
        Parameters:
        obj - Object instance on which to perform injection.
        injection - Injection containing mock to assign.
      • getTargetField

        public Field getTargetField()
        Get the field to which injections will be assigned.
        Returns:
        target field for injection assignment.