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 Detail

      • m_method

        private final MethodDeclaration m_method
        Method invocation.
    • Constructor Detail

      • MethodBuilder

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

      • getDeclaration

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

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

        public SingleVariableDeclaration addParameter​(java.lang.String name,
                                                      java.lang.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​(java.lang.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