Package Summary Overview Summary

Module java.base
Package java.lang.classfilePREVIEW

# Interface CompoundElement<E extends ClassFileElementPREVIEW>

Type Parameters:
  `E` - the element type

All Superinterfaces:
  `ClassFileElementPREVIEW`, `Iterable<E>`

All Known Subinterfaces:
  `ClassModelPREVIEW`, `CodeAttributePREVIEW`, `CodeModelPREVIEW`, `FieldModelPREVIEW`, `MethodModelPREVIEW`

public sealed interface CompoundElement<E extends ClassFileElementPREVIEW> extends ClassFileElementPREVIEW, Iterable<E> permits ClassModelPREVIEW, CodeModelPREVIEW, FieldModelPREVIEW, MethodModelPREVIEW(not exhaustive)
`CompoundElement` is a preview API of the Java platform.
Programs can only use `CompoundElement` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A `ClassFileElement`PREVIEW that has complex structure defined in terms of other classfile elements, such as a method, field, method body, or entire class. When encountering a CompoundElementPREVIEW, clients have the option to treat the element as a single entity (e.g., an entire method) or to traverse the contents of that element with the methods in this class (e.g., `elements()`, `forEachElement(Consumer)`, etc.)

Sealed Class Hierarchy Graph:
Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default List <E>`
  `elementList()`
  Returns an `List` containing all the elements contained in this compound element.
  `default Iterable <E>`
  `elements()`
  Returns an `Iterable` describing all the elements contained in this compound element.
  `default Stream <E>`
  `elementStream()`
  Returns a `Stream` containing all the elements contained in this compound element.
  `void`
  `forEachElement (Consumer<E> consumer)`
  Invoke the provided handler with each element contained in this compound element
  `default Iterator <E>`
  `iterator()`
  Returns an `Iterator` describing all the elements contained in this compound element.

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

  `forEach, spliterator`

- ## Method Details

  - ### forEachElement

    void forEachElement (Consumer<E> consumer)
    Invoke the provided handler with each element contained in this compound element
    Parameters:
      `consumer` - the handler

  - ### elements

    default Iterable<E> elements()
    Returns an `Iterable` describing all the elements contained in this compound element.
    Returns:
      an `Iterable` describing all the elements contained in this compound element

  - ### iterator

    default Iterator<E> iterator()
    Returns an `Iterator` describing all the elements contained in this compound element.
    Specified by:
      `iterator` in interface `Iterable<E extends ClassFileElementPREVIEW>`
    Returns:
      an `Iterator` describing all the elements contained in this compound element

  - ### elementStream

    default Stream<E> elementStream()
    Returns a `Stream` containing all the elements contained in this compound element.
    Returns:
      a `Stream` containing all the elements contained in this compound element

  - ### elementList

    default List<E> elementList()
    Returns an `List` containing all the elements contained in this compound element.
    Returns:
      an `List` containing all the elements contained in this compound element