Interface MethodBuilder

All Superinterfaces:
ClassFileBuilder<MethodElement, MethodBuilder>, Consumer<MethodElement>

public sealed interface MethodBuilder extends ClassFileBuilder<MethodElement, MethodBuilder>
A builder for methods. Builders are not created directly; they are passed to handlers by methods such as ClassBuilder.withMethod(Utf8Entry, Utf8Entry, int, Consumer) or to method transforms. The elements of a method can be specified abstractly (by passing a MethodElement to ClassFileBuilder.with(ClassFileElement) or concretely by calling the various withXxx methods.
Since:
24
See Also:
  • Method Details

    • withFlags

      default MethodBuilder withFlags(int flags)
      Sets the method access flags.
      Parameters:
      flags - the access flags, as a bit mask
      Returns:
      this builder
    • withFlags

      default MethodBuilder withFlags(AccessFlag... flags)
      Sets the method access flags.
      Parameters:
      flags - the access flags, as a bit mask
      Returns:
      this builder
    • withCode

      MethodBuilder withCode(Consumer<? super CodeBuilder> code)
      Build the method body for this method.
      Parameters:
      code - a handler receiving a CodeBuilder
      Returns:
      this builder
    • transformCode

      MethodBuilder transformCode(CodeModel code, CodeTransform transform)
      Build the method body for this method by transforming the body of another method.
      Implementation Note:

      This method behaves as if:

          withCode(b -> b.transformCode(code, transform));
      
      Parameters:
      code - the method body to be transformed
      transform - the transform to apply to the method body
      Returns:
      this builder