- All Superinterfaces:
ClassFileBuilder<MethodElement,,MethodBuilder> Consumer<MethodElement>
- All Known Subinterfaces:
TerminalMethodBuilder
- All Known Implementing Classes:
BufferedMethodBuilder,ChainedMethodBuilder,DirectMethodBuilder
public sealed interface MethodBuilder
extends ClassFileBuilder<MethodElement,MethodBuilder>
permits ChainedMethodBuilder, TerminalMethodBuilder
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:
- 22
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionoriginal()Returns theMethodModelrepresenting the method being transformed, if this method builder represents the transformation of someMethodModel.transformCode(CodeModel code, CodeTransform transform) Build the method body for this method by transforming the body of another method.withCode(Consumer<? super CodeBuilder> code) Build the method body for this method.default MethodBuilderwithFlags(int flags) Sets the method access flags.default MethodBuilderwithFlags(AccessFlag... flags) Sets the method access flags.Methods inherited from interface org.glavo.classfile.ClassFileBuilder
accept, canWriteDirect, constantPool, transform, with
-
Method Details
-
original
Optional<MethodModel> original()Returns theMethodModelrepresenting the method being transformed, if this method builder represents the transformation of someMethodModel.- Returns:
- the
MethodModelrepresenting the method being transformed, if this method builder represents the transformation of someMethodModel
-
withFlags
Sets the method access flags.- Parameters:
flags- the access flags, as a bit mask- Returns:
- this builder
-
withFlags
Sets the method access flags.- Parameters:
flags- the access flags, as a bit mask- Returns:
- this builder
-
withCode
Build the method body for this method.- Parameters:
code- a handler receiving aCodeBuilder- Returns:
- this builder
-
transformCode
Build the method body for this method by transforming the body of another method.- Parameters:
code- the method body to be transformedtransform- the transform to apply to the method body- Returns:
- this builder
- ImplNote:
This method behaves as if:
withCode(b -> b.transformCode(code, transform));
-