Class MethodBuilder


public class MethodBuilder extends BodyBuilderBase
Abstract syntax tree method declaration builder. This adds convenience methods and control information to the base builder.
  • Field Details

    • m_method

      private final MethodDeclaration m_method
      Method invocation.
  • Constructor Details

    • MethodBuilder

      public MethodBuilder(ClassBuilder source, MethodDeclaration method)
      Constructor.
      Parameters:
      source -
      method -
  • Method Details

    • getDeclaration

      public MethodDeclaration getDeclaration()
      Get the method declaration.
      Returns:
      declaration
    • addParameter

      public SingleVariableDeclaration addParameter(String name, Type type)
      Add a method parameter.
      Parameters:
      name -
      type -
      Returns:
      declaration
    • addParameter

      public SingleVariableDeclaration addParameter(String name, String type)
      Add a method parameter.
      Parameters:
      name -
      type - fully-qualfied type name, or primitive name, with optional array suffixes
      Returns:
      declaration
    • addThrows

      public void addThrows(String type)
      Add an exception type to those thrown by the method.
      Parameters:
      type - exception type
    • createBlock

      public BlockBuilder createBlock()
      Create a block builder for the method body.
      Returns:
      builder