Module java.base
Package java.lang.classfilePREVIEW

# Interface MethodModel

All Superinterfaces:
  `AttributedElementPREVIEW`, `ClassElementPREVIEW`, `ClassFileElementPREVIEW`, `CompoundElementPREVIEW<MethodElementPREVIEW>`, `Iterable<MethodElementPREVIEW>`, `WritableElementPREVIEW<MethodModelPREVIEW>`

public sealed interface MethodModel extends WritableElementPREVIEW<MethodModelPREVIEW>, CompoundElementPREVIEW<MethodElementPREVIEW>, AttributedElementPREVIEW, ClassElementPREVIEW
`MethodModel` is a preview API of the Java platform.
Programs can only use `MethodModel` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models a method. The contents of the method can be traversed via a streaming view (e.g., `CompoundElement.elements()`PREVIEW), or via random access (e.g., `flags()`), or by freely mixing the two.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Optional<CodeModelPREVIEW>`
  `code()`
  Returns the body of this method, if there is one.
  `AccessFlagsPREVIEW`
  `flags()`
  Returns the access flags.
  `Utf8EntryPREVIEW`
  `methodName()`
  Returns the name of this method.
  `Utf8EntryPREVIEW`
  `methodType()`
  Returns the method descriptor of this method.
  `default MethodTypeDesc`
  `methodTypeSymbol()`
  Returns the method descriptor of this method, as a symbolic descriptor.
  `Optional<ClassModelPREVIEW>`
  `parent()`
  Returns the class model this method is a member of, if known.

  ### Methods declared in interface java.lang.classfile.AttributedElementPREVIEW

  `attributes, findAttribute, findAttributes`

  ### Methods declared in interface java.lang.classfile.CompoundElementPREVIEW

  `elementList, elements, elementStream, forEachElement, iterator`

  ### Methods declared in interface java.lang.Iterable

  `forEach, spliterator`

  ### Methods declared in interface java.lang.classfile.WritableElementPREVIEW

  `writeTo`

- ## Method Details

  - ### flags

    AccessFlagsPREVIEW flags()
    Returns the access flags.
    Returns:
      the access flags

  - ### parent

    Optional<ClassModelPREVIEW> parent()
    Returns the class model this method is a member of, if known.
    Returns:
      the class model this method is a member of, if known

  - ### methodName

    Utf8EntryPREVIEW methodName()
    Returns the name of this method.
    Returns:
      the name of this method

  - ### methodType

    Utf8EntryPREVIEW methodType()
    Returns the method descriptor of this method.
    Returns:
      the method descriptor of this method

  - ### methodTypeSymbol

    default MethodTypeDesc methodTypeSymbol()
    Returns the method descriptor of this method, as a symbolic descriptor.
    Returns:
      the method descriptor of this method, as a symbolic descriptor

  - ### code

    Optional<CodeModelPREVIEW> code()
    Returns the body of this method, if there is one.
    Returns:
      the body of this method, if there is one