APIdia Launch Partner
Top Description Methods
java.lang.classfile

public sealed Interface CompoundElement<E extends ClassFileElement>

extends ClassFileElement, Iterable<E extends ClassFileElement>
permits ClassModel, CodeModel, FieldModel, MethodModel, AbstractUnboundModel<E extends ClassFileElement>
Known Direct Subinterfaces
java.lang.classfile.FieldModel, java.lang.classfile.MethodModel, java.lang.classfile.ClassModel, java.lang.classfile.CodeModel
Known Direct Implementers
jdk.internal.classfile.impl.AbstractUnboundModel
Type Parameters
<E>
the member element type
Imports
java.util.ArrayList, .Collections, .Iterator, .List, .Spliterator, .Spliterators, java.util.function.Consumer, java.util.stream.Stream, .StreamSupport, jdk.internal.classfile.components.ClassPrinter

A 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.

Since
24
See Also
Membership Elements, ClassFileBuilder

Method Summary

Modifier and TypeMethod and Description
public default List<E>

Returns:

a List containing all member elements in this compound element
elementList
()

Returns a List containing all member elements in this compound element.

public default Stream<E>

Returns:

a Stream containing all member elements in this compound element
elementStream
()

Returns a Stream containing all member elements in this compound element.

public void
forEach(Consumer<? super E>
the handler
consumer
)

Redeclares as abstract: java.lang.Iterable.forEach.

Invokes the provided handler with each member element in this compound element.

public default Iterator<E>

Returns:

an Iterator describing all member elements in this compound element
iterator
()

Implements java.lang.Iterable.iterator.

Returns an Iterator describing all member elements in this compound element.

public default String

Returns:

a text representation of the compound element and its contents for debugging purposes
toDebugString
()

Returns a text representation of the compound element and its contents for debugging purposes.

Inherited from java.lang.Iterable:
spliterator

Method Detail

elementListback to summary
public default List<E> elementList()

Returns a List containing all member elements in this compound element.

Returns:List<E>

a List containing all member elements in this compound element

elementStreamback to summary
public default Stream<E> elementStream()

Returns a Stream containing all member elements in this compound element.

Returns:Stream<E>

a Stream containing all member elements in this compound element

forEachback to summary
public void forEach(Consumer<? super E> consumer)

Redeclares as abstract: java.lang.Iterable.forEach.

Invokes the provided handler with each member element in this compound element.

Parameters
consumer:Consumer<? super E>

the handler

Annotations
@Override
iteratorback to summary
public default Iterator<E> iterator()

Implements java.lang.Iterable.iterator.

Returns an Iterator describing all member elements in this compound element.

Returns:Iterator<E>

an Iterator describing all member elements in this compound element

Annotations
@Override
toDebugStringback to summary
public default String toDebugString()

Returns a text representation of the compound element and its contents for debugging purposes. The format, structure and exact contents of the returned string are not specified and may change at any time in the future.

Returns:String

a text representation of the compound element and its contents for debugging purposes