Class InjectionNodes.InjectionNode

java.lang.Object
org.spongepowered.asm.mixin.injection.struct.InjectionNodes.InjectionNode
All Implemented Interfaces:
Comparable<InjectionNodes.InjectionNode>
Enclosing class:
InjectionNodes

public static class InjectionNodes.InjectionNode extends Object implements Comparable<InjectionNodes.InjectionNode>
A node targetted by one or more injectors. Using this wrapper allows injectors to be aware of when their target node is removed or replace by another injector. It also allows injectors to decorate certain nodes with custom metadata to allow arbitration between injectors to take place.
  • Constructor Details

    • InjectionNode

      public InjectionNode(org.objectweb.asm.tree.AbstractInsnNode node)
      Create a new node wrapper for the specified target node
      Parameters:
      node - target node
  • Method Details

    • getId

      public int getId()
      Get the unique id for this injector
    • getOriginalTarget

      public org.objectweb.asm.tree.AbstractInsnNode getOriginalTarget()
      Get the original target of this node
    • getCurrentTarget

      public org.objectweb.asm.tree.AbstractInsnNode getCurrentTarget()
      Get the current target of this node, can be null if the node was replaced
    • replace

      public InjectionNodes.InjectionNode replace(org.objectweb.asm.tree.AbstractInsnNode target)
      Replace this node with the specified target
      Parameters:
      target - new node
    • remove

      Remove the node
    • matches

      public boolean matches(org.objectweb.asm.tree.AbstractInsnNode node)
      Checks whether the original or current target of this node match the specified node
      Parameters:
      node - node to check
      Returns:
      true if the supplied node matches either of this node's internal identities
    • isReplaced

      public boolean isReplaced()
      Get whether this node has been replaced
    • isRemoved

      public boolean isRemoved()
      Get whether this node has been removed
    • decorate

      public <V> InjectionNodes.InjectionNode decorate(String key, V value)
      Decorate this node with arbitrary metadata for injector arbitration
      Type Parameters:
      V - value type
      Parameters:
      key - meta key
      value - meta value
    • hasDecoration

      public boolean hasDecoration(String key)
      Get whether this node is decorated with the specified key
      Parameters:
      key - meta key
      Returns:
      true if the specified decoration exists
    • getDecoration

      public <V> V getDecoration(String key)
      Get the specified decoration
      Type Parameters:
      V - value type
      Parameters:
      key - meta key
      Returns:
      decoration value or null if absent
    • getDecoration

      public <V> V getDecoration(String key, V defaultValue)
      Get the specified decoration or default value
      Type Parameters:
      V - value type
      Parameters:
      key - meta key
      defaultValue - default value to return
      Returns:
      decoration value or null if absent
    • compareTo

      public int compareTo(InjectionNodes.InjectionNode other)
      Specified by:
      compareTo in interface Comparable<InjectionNodes.InjectionNode>
    • toString

      public String toString()
      Overrides:
      toString in class Object