E - the member element typeClassFileElement, Iterable<E>ClassModel, CodeAttribute, CodeModel, FieldModel, MethodModelpublic sealed interface CompoundElement<E extends ClassFileElement> extends ClassFileElement, Iterable<E> permits ClassModel, CodeModel, FieldModel, MethodModel (not exhaustive)
class file structure that can be viewed as a composition of its member structures. CompoundElement allows users to traverse these member elements with forEach(Consumer) or elementStream(), or buffer the elements obtained from the traversal through iterator() or elementList(). Unless otherwise specified, all member elements of compatible type will be presented during the traversal if they exist in this element. Some member elements specify that they may appear at most once in this element; if such elements are presented multiple times, the latest occurrence is authentic and all previous occurrences should be ignored.
CompoundElements can be constructed by ClassFileBuilders. ClassFileBuilder.transform(CompoundElement, ClassFileTransform) provides an easy way to create a new structure by selectively processing the original member structures and directing the results to the builder.
| Modifier and Type | Method | Description |
|---|---|---|
default List |
elementList() |
Returns a List containing all member elements in this compound element. |
default Stream |
elementStream() |
Returns a Stream containing all member elements in this compound element. |
void |
forEach |
Invokes the provided handler with each member element in this compound element. |
default Iterator |
iterator() |
Returns an Iterator describing all member elements in this compound element. |
default String |
toDebugString() |
Returns a text representation of the compound element and its contents for debugging purposes. |
spliterator
void forEach(Consumer<? super E> consumer)
forEach in interface Iterable<E extends ClassFileElement>
consumer - the handlerdefault String toDebugString()
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/classfile/CompoundElement.html