java.lang.Object
org.matwoess.jsourceprofiler.tool.model.Method
All Implemented Interfaces:
Serializable, Component

public class Method extends Object implements Serializable, Component
Model class representing a java method.

Stores the containing class, the method name and the block representing the method body.

See Also:
  • Field Details

    • name

      public final String name
    • parentClass

      public JClass parentClass
    • methodBlock

      public Block methodBlock
  • Constructor Details

    • Method

      public Method(String name)
      Creates a new Method with the given name.
      Parameters:
      name - the name of the method
  • Method Details

    • setParentClass

      public void setParentClass(JClass parentClass)
      Stores the given class as the parent class of this method.

      Additionally, this method is added to the list of methods for the parent class.

      Parameters:
      parentClass - the parent class
    • setMethodBlock

      public void setMethodBlock(Block block)
      Sets the given block as the method body.
      Parameters:
      block - the method body block
    • getMethodBlock

      public Block getMethodBlock()
      Returns the block representing the method body.
      Returns:
      the method body block
    • getBlocksRecursive

      public List<Block> getBlocksRecursive()
      Returns a list of all blocks in this method, including inner blocks recursively.

      If this method is abstract, an empty list is returned.

      Returns:
      the list of all blocks in this method
    • isAbstract

      public boolean isAbstract()
      Whether this method is abstract.
      Returns:
      true if this method has no body-block
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object