Module java.base
Package java.lang.classfilePREVIEW

# Interface FieldBuilder

All Superinterfaces:
  `ClassFileBuilderPREVIEW<FieldElementPREVIEW,FieldBuilderPREVIEW>`, `Consumer<FieldElementPREVIEW>`

public sealed interface FieldBuilder extends ClassFileBuilderPREVIEW<FieldElementPREVIEW,FieldBuilderPREVIEW>
`FieldBuilder` is a preview API of the Java platform.
Programs can only use `FieldBuilder` 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 fields. Builders are not created directly; they are passed to handlers by methods such as `ClassBuilder.withField(Utf8Entry, Utf8Entry, Consumer)`PREVIEW or to field transforms. The elements of a field can be specified abstractly (by passing a `FieldElement`PREVIEW to `ClassFileBuilder.with(ClassFileElement)`PREVIEW or concretely by calling the various `withXxx` methods.

Since:
  22
See Also:
  - `FieldTransform`PREVIEW

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Optional<FieldModelPREVIEW>`
  `original()`
  Returns the `FieldModel`PREVIEW representing the field being transformed, if this field builder represents the transformation of some `FieldModel`PREVIEW.
  `default FieldBuilderPREVIEW`
  `withFlags(int flags)`
  Sets the field access flags.
  `default FieldBuilderPREVIEW`
  `withFlags(AccessFlag... flags)`
  Sets the field access flags.

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

  `accept, canWriteDirect, constantPool, transform, with`

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

  `andThen`

- ## Method Details

  - ### withFlags

    default FieldBuilderPREVIEW withFlags(int flags)
    Sets the field access flags.
    Parameters:
      `flags` - the access flags, as a bit mask
    Returns:
      this builder

  - ### withFlags

    default FieldBuilderPREVIEW withFlags(AccessFlag... flags)
    Sets the field access flags.
    Parameters:
      `flags` - the access flags, as a bit mask
    Returns:
      this builder

  - ### original

    Optional<FieldModelPREVIEW> original()
    Returns the `FieldModel`PREVIEW representing the field being transformed, if this field builder represents the transformation of some `FieldModel`PREVIEW.
    Returns:
      the `FieldModel`PREVIEW representing the field being transformed, if this field builder represents the transformation of some `FieldModel`PREVIEW