Record Class MethodOrConstructor

java.lang.Object
java.lang.Record
io.codemodder.remediation.MethodOrConstructor

public record MethodOrConstructor(com.github.javaparser.ast.Node node) extends Record
Convenience type to represent a method or constructor call in our APIs that work with both.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MethodOrConstructor(com.github.javaparser.ast.Node node)
    Creates an instance of a MethodOrConstructor record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.github.javaparser.ast.expr.MethodCallExpr
    Return the wrapped node as a MethodCallExpr or blow up.
    com.github.javaparser.ast.Node
    Return the wrapped node as a Node.
    com.github.javaparser.ast.nodeTypes.NodeWithArguments<?>
    Return the wrapped node as a NodeWithArguments.
    com.github.javaparser.ast.expr.ObjectCreationExpr
    Return the wrapped node as a ObjectCreationExpr or blow up.
    final boolean
    Indicates whether some other object is "equal to" this one.
    com.github.javaparser.ast.NodeList<?>
    Get the arguments for the call.
    com.github.javaparser.Range
    This assumes a range is present, and explodes if it doesn't.
    final int
    Returns a hash code value for this object.
    boolean
    Return true if the node has a range, meaning it was not added by us.
    boolean
    Return true if this is a constructor call.
    boolean
    Return true if this is a constructor call for the given type.
    boolean
    Return true if this is a method call.
    boolean
    Return true if this is a method call and it has the given name.
    boolean
    Return true if this is a method call and it has one of the given names.
    boolean
    Return true if this is a method call with a scope.
    com.github.javaparser.ast.Node
    Returns the value of the node record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MethodOrConstructor

      public MethodOrConstructor(com.github.javaparser.ast.Node node)
      Creates an instance of a MethodOrConstructor record class.
      Parameters:
      node - the value for the node record component
  • Method Details

    • asNode

      public com.github.javaparser.ast.Node asNode()
      Return the wrapped node as a Node.
    • getRange

      public com.github.javaparser.Range getRange()
      This assumes a range is present, and explodes if it doesn't.
    • asNodeWithArguments

      public com.github.javaparser.ast.nodeTypes.NodeWithArguments<?> asNodeWithArguments()
      Return the wrapped node as a NodeWithArguments.
    • getArguments

      public com.github.javaparser.ast.NodeList<?> getArguments()
      Get the arguments for the call.
    • isConstructor

      public boolean isConstructor()
      Return true if this is a constructor call.
    • isMethodCall

      public boolean isMethodCall()
      Return true if this is a method call.
    • isMethodCallWithScope

      public boolean isMethodCallWithScope()
      Return true if this is a method call with a scope.
    • isConstructorForType

      public boolean isConstructorForType(String type)
      Return true if this is a constructor call for the given type.
    • hasRange

      public boolean hasRange()
      Return true if the node has a range, meaning it was not added by us.
    • isMethodCallWithName

      public boolean isMethodCallWithName(String name)
      Return true if this is a method call and it has the given name.
    • isMethodCallWithNameIn

      public boolean isMethodCallWithNameIn(Collection<String> names)
      Return true if this is a method call and it has one of the given names.
    • asMethodCall

      public com.github.javaparser.ast.expr.MethodCallExpr asMethodCall()
      Return the wrapped node as a MethodCallExpr or blow up.
    • asObjectCreationExpr

      public com.github.javaparser.ast.expr.ObjectCreationExpr asObjectCreationExpr()
      Return the wrapped node as a ObjectCreationExpr or blow up.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • node

      public com.github.javaparser.ast.Node node()
      Returns the value of the node record component.
      Returns:
      the value of the node record component