Package org.spongepowered.asm.mixin.injection.struct

## Class InjectionInfo

- java.lang.Object
- - org.spongepowered.asm.mixin.struct.AnnotatedMethodInfo
  - - org.spongepowered.asm.mixin.struct.SpecialMethodInfo
    - - org.spongepowered.asm.mixin.injection.struct.InjectionInfo

- All Implemented Interfaces:
    `ISliceContext`, `IInjectionPointContext`, `ISelectorContext`, `IMessageSink`
  Direct Known Subclasses:
    `CallbackInjectionInfo`, `ModifyArgInjectionInfo`, `ModifyArgsInjectionInfo`, `ModifyConstantInjectionInfo`, `ModifyVariableInjectionInfo`, `RedirectInjectionInfo`

      public abstract class InjectionInfo
      extends SpecialMethodInfo
      implements ISliceContext

  Contructs information about an injection from an `Inject` annotation and allows the injection to be processed.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static interface` | `InjectionInfo.AnnotationType` | Decoration for subclasses which indicates the injector annotation that the subclass handles
    `static interface` | `InjectionInfo.HandlerPrefix` | Decoration for subclasses which specifies the prefix to use when conforming annotated handler methods
    `static interface` | `InjectionInfo.InjectorOrder` | Decoration for subclasses which specifies the order (phase) in which the injector should be applied relative to other injectors.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected ActivityStack` | `activities` | Activity tracker
    `protected java.lang.String` | `atKey` | The key into the annotation which contains the injection points
    `protected InjectorGroupInfo` | `group` | Injection group
    `protected java.util.List<org.objectweb.asm.tree.AnnotationNode>` | `injectionPointAnnotations` |
    `protected java.util.List<InjectionPoint>` | `injectionPoints` | Injection points parsed from `At` annotations
    `protected Injector` | `injector` | Bytecode injector
    `protected boolean` | `isStatic` | Annotated method is static
    `protected MethodSlices` | `slices` | Method slice descriptors parsed from the annotation
    `protected int` | `targetCount` | Number of target methods identified by the injection points
    `protected java.util.Map<Target,​java.util.List<InjectionNodes.InjectionNode>>` | `targetNodes` | Map of lists of nodes enumerated by calling `prepare()`
    `protected TargetSelectors` | `targets` | Targets

    - ### Fields inherited from class org.spongepowered.asm.mixin.struct.SpecialMethodInfo

      `classNode, mixin`

    - ### Fields inherited from class org.spongepowered.asm.mixin.struct.AnnotatedMethodInfo

      `annotation, annotationType, method, methodName`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `InjectionInfo​(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method, org.objectweb.asm.tree.AnnotationNode annotation)` | ctor
    `protected` | `InjectionInfo​(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method, org.objectweb.asm.tree.AnnotationNode annotation, java.lang.String atKey)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addCallbackInvocation​(org.objectweb.asm.tree.MethodNode handler)` | Notify method, called by injector when adding a callback into a target
    `void` | `addMessage​(java.lang.String format, java.lang.Object... args)` | Notify method, called by injector or injection point when a notable but non-fatal failures occur, for example allows injection points to add notes when they return no results.
    `org.objectweb.asm.tree.MethodNode` | `addMethod​(int access, java.lang.String name, java.lang.String desc)` | Inject a method into the target class
    `protected java.lang.String` | `getDescription()` |
    `int` | `getInjectedCallbackCount()` | Get the injected callback count
    `static org.objectweb.asm.tree.AnnotationNode` | `getInjectorAnnotation​(IMixinInfo mixin, org.objectweb.asm.tree.MethodNode method)` | Returns any injector annotation found on the specified method.
    `static java.lang.String` | `getInjectorPrefix​(org.objectweb.asm.tree.AnnotationNode annotation)` | Get the conform prefix for an injector handler by type
    `protected java.lang.String` | `getMessages()` |
    `int` | `getOrder()` | Get the application order for this injector type
    `static java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>>` | `getRegisteredAnnotations()` |
    `MethodSlice` | `getSlice​(java.lang.String id)` | Get the slice descriptors
    `java.lang.String` | `getSliceId​(java.lang.String id)` | Return the mapped slice id for the specified ID.
    `int` | `getTargetCount()` | Get number of methods being injected into
    `void` | `inject()` | Perform injections
    `boolean` | `isValid()` | Get whether there is enough valid information in this info to actually perform an injection.
    `void` | `notifyInjected​(Target target)` | Callback from injector which notifies us that a callback was injected.
    `static InjectionInfo` | `parse​(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method)` | Parse an injector from the specified method (if an injector annotation is present).
    `protected void` | `parseInjectionPoints​(java.util.List<org.objectweb.asm.tree.AnnotationNode> ats)` |
    `protected abstract Injector` | `parseInjector​(org.objectweb.asm.tree.AnnotationNode injectAnnotation)` |
    `protected void` | `parseOrder()` |
    `protected void` | `parseRequirements()` |
    `protected void` | `parseSelectors()` |
    `void` | `postInject()` | Perform cleanup and post-injection tasks
    `void` | `preInject()` | Perform pre-injection checks and tasks
    `void` | `prepare()` | Discover injection points
    `protected void` | `readAnnotation()` | Parse the info from the supplied annotation
    `protected void` | `readInjectionPoints()` |
    `static void` | `register​(java.lang.Class<? extends InjectionInfo> type)` | Register an injector info class.
    `java.lang.String` | `toString()` |

    - ### Methods inherited from class org.spongepowered.asm.mixin.struct.SpecialMethodInfo

      `getClassInfo, getClassNode, getMethodName, getTargetClassInfo, getTargetClassNode`

    - ### Methods inherited from class org.spongepowered.asm.mixin.struct.AnnotatedMethodInfo

      `getAnnotation, getAnnotationNode, getDynamicInfo, getDynamicInfo, getDynamicInfo, getElementDescription, getMethod, getMixin, getParent, getSelectorAnnotation, getSelectorCoordinate, remap`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.spongepowered.asm.mixin.injection.IInjectionPointContext

      `getAnnotationNode, getMethod`

    - ### Methods inherited from interface org.spongepowered.asm.mixin.injection.selectors.ISelectorContext

      `getAnnotation, getElementDescription, getMixin, getParent, getSelectorAnnotation, getSelectorCoordinate, remap`

- - ### Field Detail

    - #### activities

          protected final ActivityStack activities

      Activity tracker

    - #### isStatic

          protected final boolean isStatic

      Annotated method is static

    - #### targets

          protected final TargetSelectors targets

      Targets

    - #### slices

          protected final MethodSlices slices

      Method slice descriptors parsed from the annotation

    - #### atKey

          protected final java.lang.String atKey

      The key into the annotation which contains the injection points

    - #### injectionPointAnnotations

          protected final java.util.List<org.objectweb.asm.tree.AnnotationNode> injectionPointAnnotations

    - #### injectionPoints

          protected final java.util.List<InjectionPoint> injectionPoints

      Injection points parsed from `At` annotations

    - #### targetNodes

          protected final java.util.Map<Target,​java.util.List<InjectionNodes.InjectionNode>> targetNodes

      Map of lists of nodes enumerated by calling `prepare()`

    - #### targetCount

          protected int targetCount

      Number of target methods identified by the injection points

    - #### injector

          protected Injector injector

      Bytecode injector

    - #### group

          protected InjectorGroupInfo group

      Injection group

  - ### Constructor Detail

    - #### InjectionInfo

          protected InjectionInfo​(MixinTargetContext mixin,
                                  org.objectweb.asm.tree.MethodNode method,
                                  org.objectweb.asm.tree.AnnotationNode annotation)

      ctor
      Parameters:
        `mixin` - Mixin data
        `method` - Injector method
        `annotation` - Annotation to parse

    - #### InjectionInfo

          protected InjectionInfo​(MixinTargetContext mixin,
                                  org.objectweb.asm.tree.MethodNode method,
                                  org.objectweb.asm.tree.AnnotationNode annotation,
                                  java.lang.String atKey)

  - ### Method Detail

    - #### readAnnotation

          protected void readAnnotation()

      Parse the info from the supplied annotation

    - #### readInjectionPoints

          protected void readInjectionPoints()

    - #### parseRequirements

          protected void parseRequirements()

    - #### parseOrder

          protected void parseOrder()

    - #### parseSelectors

          protected void parseSelectors()

    - #### parseInjectionPoints

          protected void parseInjectionPoints​(java.util.List<org.objectweb.asm.tree.AnnotationNode> ats)

    - #### parseInjector

          protected abstract Injector parseInjector​(org.objectweb.asm.tree.AnnotationNode injectAnnotation)

    - #### isValid

          public boolean isValid()

      Get whether there is enough valid information in this info to actually perform an injection.
      Returns:
        true if this InjectionInfo was successfully parsed

    - #### getOrder

          public int getOrder()

      Get the application order for this injector type

    - #### prepare

          public void prepare()

      Discover injection points

    - #### preInject

          public void preInject()

      Perform pre-injection checks and tasks

    - #### inject

          public void inject()

      Perform injections

    - #### postInject

          public void postInject()

      Perform cleanup and post-injection tasks

    - #### notifyInjected

          public void notifyInjected​(Target target)

      Callback from injector which notifies us that a callback was injected. No longer used.
      Parameters:
        `target` - target into which the injector injected

    - #### getDescription

          protected java.lang.String getDescription()

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getTargetCount

          public int getTargetCount()

      Get number of methods being injected into
      Returns:
        count of methods being injected into

    - #### getSlice

          public MethodSlice getSlice​(java.lang.String id)

      Get the slice descriptors
      Specified by:
        `getSlice` in interface `ISliceContext`
      Parameters:
        `id` - slice id to fetch
      Returns:
        method slice matching query

    - #### getSliceId

          public java.lang.String getSliceId​(java.lang.String id)

      Return the mapped slice id for the specified ID. Injectors which only support use of a single slice will always return the default id (an empty string)
      Parameters:
        `id` - slice id
      Returns:
        mapped id

    - #### getInjectedCallbackCount

          public int getInjectedCallbackCount()

      Get the injected callback count
      Returns:
        the injected callback count

    - #### addMethod

          public org.objectweb.asm.tree.MethodNode addMethod​(int access,
                                                             java.lang.String name,
                                                             java.lang.String desc)

      Inject a method into the target class
      Parameters:
        `access` - Method access flags, synthetic will be automatically added
        `name` - Method name
        `desc` - Method descriptor
      Returns:
        new method

    - #### addCallbackInvocation

          public void addCallbackInvocation​(org.objectweb.asm.tree.MethodNode handler)

      Notify method, called by injector when adding a callback into a target
      Parameters:
        `handler` - callback handler being invoked

    - #### addMessage

          public void addMessage​(java.lang.String format,
                                 java.lang.Object... args)

      Notify method, called by injector or injection point when a notable but non-fatal failures occur, for example allows injection points to add notes when they return no results.
      Specified by:
        `addMessage` in interface `IMessageSink`
      Overrides:
        `addMessage` in class `AnnotatedMethodInfo`
      Parameters:
        `format` - Message format
        `args` - Format args

    - #### getMessages

          protected java.lang.String getMessages()

    - #### parse

          public static InjectionInfo parse​(MixinTargetContext mixin,
                                            org.objectweb.asm.tree.MethodNode method)

      Parse an injector from the specified method (if an injector annotation is present). If no injector annotation is present then `null` is returned.
      Parameters:
        `mixin` - context
        `method` - mixin method
      Returns:
        parsed InjectionInfo or null

    - #### getInjectorAnnotation

          public static org.objectweb.asm.tree.AnnotationNode getInjectorAnnotation​(IMixinInfo mixin,
                                                                                    org.objectweb.asm.tree.MethodNode method)

      Returns any injector annotation found on the specified method. If multiple matching annotations are found then an exception is thrown. If no annotations are present then `null` is returned.
      Parameters:
        `mixin` - context
        `method` - mixin method
      Returns:
        annotation or null

    - #### getInjectorPrefix

          public static java.lang.String getInjectorPrefix​(org.objectweb.asm.tree.AnnotationNode annotation)

      Get the conform prefix for an injector handler by type
      Parameters:
        `annotation` - Annotation to inspect
      Returns:
        conform prefix

    - #### register

          public static void register​(java.lang.Class<? extends InjectionInfo> type)

      Register an injector info class. The supplied class must be decorated with an `InjectionInfo.AnnotationType` annotation for registration purposes.
      Parameters:
        `type` - injection info subclass to register

    - #### getRegisteredAnnotations

          public static java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> getRegisteredAnnotations()