Class ElementNode<TNode>
java.lang.Object
org.spongepowered.asm.mixin.injection.selectors.ElementNode<TNode>
- Type Parameters:
TNode- node type
Wrapper for all node types supported by
target
selectors (FieldNode, MethodNode, FieldInsnNode,
MethodInsnNode and InvokeDynamicInsnNode) which allows access
to common properties of things which are basically "arbitrary node with
owner, name and descriptor"-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumElement node type, returned by getType so consumers don't need to do instanceof checks, and allows switching on element type in a more expressive way -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanstatic List<ElementNode<org.objectweb.asm.tree.FieldNode>> fieldList(org.objectweb.asm.tree.ClassNode owner) Get a list of wrapped ElementNodes for the fields of the supplied owner classabstract TNodeget()Returns the node with horrible duck typingabstract StringgetDesc()Get the element descriptor.org.objectweb.asm.tree.FieldNodegetField()Get theFieldNodeif this member is a field, otherwise returns nullFor LMF elements, returns the full descriptor of the implementing method (including any leading parameters bound to it).For LMF elements, returns the real name of the implementing method.For LMF elements, returns the owner of the implementing method.org.objectweb.asm.tree.AbstractInsnNodegetInsn()Get theinstructionif this member is an insn, otherwise returns nullorg.objectweb.asm.tree.MethodNodeGet theMethodNodeif this member is a method, otherwise returns nullabstract StringgetName()Get the element nameabstract StringgetOwner()Get the element owner's name, if this element has an owner, otherwise returns null.abstract StringGet the element signature, can be nullabstract ElementNode.NodeTypegetType()Get the type of this ElementNode, the return value can be used to determine which accessor (getMethod(),getField()final inthashCode()static Iterable<ElementNode<org.objectweb.asm.tree.AbstractInsnNode>> insnList(org.objectweb.asm.tree.InsnList insns) Get a wrapped version of the supplied insn list which returns element nodes for each (supported) instruction (FieldInsnNode, MethodInsnNode and InvokeDynamicInsnNode).booleanisField()Get whether this element is a field type and the descriptor is a bare type descriptor without arguments.static <TNode> List<ElementNode<TNode>> Convert the supplied list of nodes to a list of wrapped ElementNodesstatic Iterable<ElementNode<org.objectweb.asm.tree.AbstractInsnNode>> lmfInsnList(org.objectweb.asm.tree.InsnList insns) Get a wrapped version of the supplied insn list which returns element nodes for every LMF instruction onlystatic List<ElementNode<org.objectweb.asm.tree.MethodNode>> methodList(org.objectweb.asm.tree.ClassNode owner) Get a list of wrapped ElementNodes for the methods of the supplied owner classstatic ElementNode<org.objectweb.asm.tree.FieldNode> of(org.objectweb.asm.tree.ClassNode owner, org.objectweb.asm.tree.FieldNode field) Create an ElementNode wrapper for the supplied field nodestatic ElementNode<org.objectweb.asm.tree.MethodNode> of(org.objectweb.asm.tree.ClassNode owner, org.objectweb.asm.tree.MethodNode method) Create an ElementNode wrapper for the supplied method nodestatic <TNode> ElementNode<TNode> of(org.objectweb.asm.tree.ClassNode owner, TNode node) Create an ElementNode wrapper for the supplied node objectstatic <TNode extends org.objectweb.asm.tree.AbstractInsnNode>
ElementNode<TNode> of(TNode node) Create an ElementNode wrapper for the supplied node objecttoString()
-
Constructor Details
-
ElementNode
public ElementNode()
-
-
Method Details
-
isField
public boolean isField()Get whether this element is a field type and the descriptor is a bare type descriptor without arguments. Otherwise assumes the descriptor is a method descriptor. -
getType
Get the type of this ElementNode, the return value can be used to determine which accessor (getMethod(),getField() -
getMethod
public org.objectweb.asm.tree.MethodNode getMethod()Get theMethodNodeif this member is a method, otherwise returns null -
getField
public org.objectweb.asm.tree.FieldNode getField()Get theFieldNodeif this member is a field, otherwise returns null -
getInsn
public org.objectweb.asm.tree.AbstractInsnNode getInsn()Get theinstructionif this member is an insn, otherwise returns null -
getOwner
Get the element owner's name, if this element has an owner, otherwise returns null. For LMF elements this is the SAM type being implemented. -
getImplOwner
For LMF elements, returns the owner of the implementing method. -
getName
Get the element name -
getImplName
For LMF elements, returns the real name of the implementing method. -
getDesc
Get the element descriptor. For LMF elements this is the specialised descriptor of the SAM. -
getImplDesc
For LMF elements, returns the full descriptor of the implementing method (including any leading parameters bound to it). -
getSignature
Get the element signature, can be null -
get
Returns the node with horrible duck typing -
toString
-
equals
-
hashCode
public final int hashCode() -
of
public static ElementNode<org.objectweb.asm.tree.MethodNode> of(org.objectweb.asm.tree.ClassNode owner, org.objectweb.asm.tree.MethodNode method) Create an ElementNode wrapper for the supplied method node- Parameters:
owner- class which owns the method or nullmethod- Method node to wrap- Returns:
- ElementNode
-
of
public static ElementNode<org.objectweb.asm.tree.FieldNode> of(org.objectweb.asm.tree.ClassNode owner, org.objectweb.asm.tree.FieldNode field) Create an ElementNode wrapper for the supplied field node- Parameters:
owner- class which owns the field or nullfield- Field node to wrap- Returns:
- ElementNode
-
of
Create an ElementNode wrapper for the supplied node object- Type Parameters:
TNode- Node type- Parameters:
owner- class which owns the node or nullnode- Node to wrap- Returns:
- ElementNode
- Throws:
IllegalArgumentException- if the supplied argument is not aMethodNodeorFieldNode
-
of
public static <TNode extends org.objectweb.asm.tree.AbstractInsnNode> ElementNode<TNode> of(TNode node) Create an ElementNode wrapper for the supplied node object- Type Parameters:
TNode- Node type- Parameters:
node- Node to wrap- Returns:
- ElementNode
- Throws:
IllegalArgumentException- if the supplied argument is not aMethodNodeorFieldNode
-
listOf
public static <TNode> List<ElementNode<TNode>> listOf(org.objectweb.asm.tree.ClassNode owner, List<TNode> list) Convert the supplied list of nodes to a list of wrapped ElementNodes- Type Parameters:
TNode- Node type- Parameters:
owner- Owner of the supplied nodes, can be nulllist- List of nodes- Returns:
- List of wrapped nodes
-
fieldList
public static List<ElementNode<org.objectweb.asm.tree.FieldNode>> fieldList(org.objectweb.asm.tree.ClassNode owner) Get a list of wrapped ElementNodes for the fields of the supplied owner class- Parameters:
owner- Class to get fields, must not be null- Returns:
- List of wrapped nodes
-
methodList
public static List<ElementNode<org.objectweb.asm.tree.MethodNode>> methodList(org.objectweb.asm.tree.ClassNode owner) Get a list of wrapped ElementNodes for the methods of the supplied owner class- Parameters:
owner- Class to get methods, must not be null- Returns:
- List of wrapped nodes
-
insnList
public static Iterable<ElementNode<org.objectweb.asm.tree.AbstractInsnNode>> insnList(org.objectweb.asm.tree.InsnList insns) Get a wrapped version of the supplied insn list which returns element nodes for each (supported) instruction (FieldInsnNode, MethodInsnNode and InvokeDynamicInsnNode).- Parameters:
insns- Insn list to wrap- Returns:
- Wrapper for insn list
-
lmfInsnList
public static Iterable<ElementNode<org.objectweb.asm.tree.AbstractInsnNode>> lmfInsnList(org.objectweb.asm.tree.InsnList insns) Get a wrapped version of the supplied insn list which returns element nodes for every LMF instruction only- Parameters:
insns- Insn list to wrap- Returns:
- Wrapper for insn list
-