com.atlassian.clover.api.registry

## Interface MethodInfo

- All Superinterfaces:
    ElementInfo, EntityContainer, HasAggregatedMetrics, HasBranches, HasClasses, HasContextFilter, HasMethods, HasMetrics, HasParent, HasStatements, InstrumentationInfo, SourceInfo

      public interface MethodInfo
      extends ElementInfo, SourceInfo, InstrumentationInfo, EntityContainer, HasBranches, HasClasses, HasMethods, HasStatements, HasContextFilter, HasMetrics, HasAggregatedMetrics, HasParent

  Represents a method (or an equivalent, like function) Implements interfaces:
  - HasClasses - classes declared inside a method body, for example:
    - anonymous inline class - Java, Groovy - currently Clover does not handle inline classes (it treats them as a part of the method body)
  - HasMethods - some programming languages allow to declare a method inside another method, for example:
    - a lambda expression inside a method - Java 8
    - a function inside a function - Scala, Closure
  - HasStatements, HasBranches - returns code defined in a method body
  - HasContextFilter - set of custom statement/method contexts for filtering
  - HasMetrics, HasAggregatedMetrics - code metrics for the method
  - HasParent - parent method/class/file for this method

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `ClassInfo` | `getContainingClass()` Returns a class in which method is declared or `null` if method (actually it will be a function or procedure) is declared outside the class.
    `FileInfo` | `getContainingFile()` Returns a file in which this method is declared.
    `MethodInfo` | `getContainingMethod()` Returns a method in which this method (an inner function actually) is declared or `null` if method is not nested inside other method.
    `java.lang.String` | `getName()`
    `EntityContainer` | `getParent()` Returns an object which encloses this method.
    `java.lang.String` | `getQualifiedName()`
    `MethodSignatureInfo` | `getSignature()` Returns method signature (annotations, keywords, type parameters, method name, parameters, return type, throws).
    `java.lang.String` | `getSimpleName()`
    `java.lang.String` | `getStaticTestName()` Name of the test associated with a method.
    `boolean` | `isEmpty()` Returns whether method is empty, i.e.
    `boolean` | `isLambda()` Returns whether it's a lambda function or not.
    `boolean` | `isTest()` Returns whether it's a test method or not.

    - ### Methods inherited from interface com.atlassian.clover.api.registry.ElementInfo

      `getComplexity, getContext, getHitCount`

    - ### Methods inherited from interface com.atlassian.clover.api.registry.SourceInfo

      `getEndColumn, getEndLine, getStartColumn, getStartLine`

    - ### Methods inherited from interface com.atlassian.clover.api.registry.InstrumentationInfo

      `getDataIndex, getDataLength`

    - ### Methods inherited from interface com.atlassian.clover.api.registry.EntityContainer

      `visit`

    - ### Methods inherited from interface com.atlassian.clover.api.registry.HasBranches

      `getBranches`

    - ### Methods inherited from interface com.atlassian.clover.api.registry.HasClasses

      `getAllClasses, getClasses`

    - ### Methods inherited from interface com.atlassian.clover.api.registry.HasMethods

      `getAllMethods, getMethods`

    - ### Methods inherited from interface com.atlassian.clover.api.registry.HasStatements

      `getStatements`

    - ### Methods inherited from interface com.atlassian.clover.api.registry.HasContextFilter

      `getContextFilter`

    - ### Methods inherited from interface com.atlassian.clover.api.registry.HasMetrics

      `getMetrics, getRawMetrics, setMetrics`

    - ### Methods inherited from interface com.atlassian.clover.api.registry.HasAggregatedMetrics

      `getAggregatedComplexity, getAggregatedStatementCount, setAggregatedComplexity, setAggregatedStatementCount`

- - ### Method Detail

    - #### getName

          java.lang.String getName()

      Specified by:
        `getName` in interface `HasMetrics`

    - #### getSimpleName

          java.lang.String getSimpleName()

    - #### getQualifiedName

          java.lang.String getQualifiedName()

    - #### getContainingClass

          @Nullable
          ClassInfo getContainingClass()

      Returns a class in which method is declared or `null` if method (actually it will be a function or procedure) is declared outside the class.
      Returns:
        ClassInfo containing class or `null`

    - #### getContainingMethod

          @Nullable
          MethodInfo getContainingMethod()

      Returns a method in which this method (an inner function actually) is declared or `null` if method is not nested inside other method.
      Returns:
        MethodInfo containing method or `null`

    - #### getContainingFile

          @Nullable
          FileInfo getContainingFile()

      Returns a file in which this method is declared. Note that some programming languages allows to define a function outside a class (or other function).
      Returns:
        FileInfo file containing this method

    - #### getParent

          @NotNull
          EntityContainer getParent()

      Returns an object which encloses this method. You can access it via:
      - `EntityVisitor.visitClass(ClassInfo)` - for a method declared inside a class
      - `EntityVisitor.visitMethod(MethodInfo)` - for a method declared inside another method
      - `EntityVisitor.visitFile(FileInfo)` - for a method declared in the file (on a top-level)
      Specified by:
        `getParent` in interface `HasParent`
      Returns:
        EntityContainer parent code entity

    - #### isEmpty

          boolean isEmpty()

      Returns whether method is empty, i.e. does not contain any executable code in it - no statements or branches. Nested methods (functions) and classes defined inside the method body are treated separately, i.e. a method having them can still be empty if it has no statements or branches.
      Returns:
        boolean true if has no statements and no branches, false otherwise

    - #### getSignature

          @NotNull
          MethodSignatureInfo getSignature()

      Returns method signature (annotations, keywords, type parameters, method name, parameters, return type, throws).
      Returns:
        MethodSignatureInfo

    - #### isTest

          boolean isTest()

      Returns whether it's a test method or not. Classification as a test method depends on the test pattern defined at instrumentation time.
      Returns:
        boolean true if test method, false otherwise

    - #### getStaticTestName

          @Nullable
          java.lang.String getStaticTestName()

      Name of the test associated with a method. Some test frameworks can declare a name of the test using annotations or javadoc tags, so that later the test name and not the original method name is used in reporting. For instance, the Spock framweork uses @FeatureMetadata(name="name of the test") Note that this method returns a static name of the test, i.e. declared in the code. Some test frameworks might dynamically generate test names. Examples are the Spock's @Unroll and JUnit's @Parameterized.
      Returns:
        String name of the test associated to this method or `null` if not declared

    - #### isLambda

          boolean isLambda()

      Returns whether it's a lambda function or not.
      Returns:
        boolean `true` for lambda function, false otherwise