Package Summary Overview Summary

Module java.base
Package java.lang.classfilePREVIEW

# Interface ClassFileBuilder<E extends ClassFileElementPREVIEW, B extends ClassFileBuilderPREVIEW<E, B>>

Type Parameters:
  `E` - the element type
  `B` - the builder type

All Superinterfaces:
  `Consumer<E>`

All Known Subinterfaces:
  `ClassBuilderPREVIEW`, `CodeBuilderPREVIEW`, `CodeBuilder.BlockCodeBuilderPREVIEW`, `FieldBuilderPREVIEW`, `MethodBuilderPREVIEW`

public sealed interface ClassFileBuilder<E extends ClassFileElementPREVIEW, B extends ClassFileBuilderPREVIEW<E, B>> extends Consumer<E> permits ClassBuilderPREVIEW, FieldBuilderPREVIEW, MethodBuilderPREVIEW, CodeBuilderPREVIEW
`ClassFileBuilder` is a preview API of the Java platform.
Programs can only use `ClassFileBuilder` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A builder for a classfile or portion of a classfile. Builders are rarely created directly; they are passed to handlers by methods such as `ClassFile.build(ClassDesc, Consumer)` PREVIEW or to transforms. Elements of the newly built entity can be specified abstractly (by passing a `ClassFileElement`PREVIEW to `with(ClassFileElement)` or concretely by calling the various `withXxx` methods.

Sealed Class Hierarchy Graph:
Since:
  22
See Also:
  - `ClassFileTransform`PREVIEW

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default void`
  `accept (E e)`
  Integrate the `ClassFileElement`PREVIEW into the entity being built.
  `default boolean`
  `canWriteDirect (ConstantPoolPREVIEW source)`
  Returns whether the provided constant pool is compatible with this builder.
  `ConstantPoolBuilderPREVIEW`
  `constantPool()`
  Returns the constant pool builder associated with this builder.
  `default void`
  `transform (CompoundElementPREVIEW<E> model, ClassFileTransformPREVIEW<?, E, B> transform)`
  Apply a transform to a model, directing results to this builder.
  `B`
  `with (E e)`
  Integrate the `ClassFileElement`PREVIEW into the entity being built.

  ### Methods declared in interface java.util.function.Consumer

  `andThen`

- ## Method Details

  - ### accept

    default void accept (E e)
    Integrate the `ClassFileElement`PREVIEW into the entity being built.
    Specified by:
      `accept` in interface `Consumer<E extends ClassFileElementPREVIEW>`
    Parameters:
      `e` - the element

  - ### with

    B with (E e)
    Integrate the `ClassFileElement`PREVIEW into the entity being built.
    Parameters:
      `e` - the element
    Returns:
      this builder

  - ### constantPool

    ConstantPoolBuilderPREVIEW constantPool()
    Returns the constant pool builder associated with this builder.
    Returns:
      the constant pool builder associated with this builder

  - ### canWriteDirect

    default boolean canWriteDirect (ConstantPoolPREVIEW source)
    Returns whether the provided constant pool is compatible with this builder.
    Parameters:
      `source` - the constant pool to test compatibility with
    Returns:
      whether the provided constant pool is compatible with this builder

  - ### transform

    default void transform (CompoundElementPREVIEW<E> model, ClassFileTransformPREVIEW<?, E, B> transform)
    Apply a transform to a model, directing results to this builder.
    Parameters:
      `model` - the model to transform
      `transform` - the transform to apply