ClassFile.AttributeMapperOption (Java SE 25 & JDK 25)
Description: declaration: module: java.base, package: java.lang.classfile, interface: ClassFile, interface: AttributeMapperOption
Keywords: java.lang.classfile.ClassFile.AttributeMapperOption interface

# Interface ClassFile.AttributeMapperOption

All Superinterfaces:
  `ClassFile.Option`

Enclosing interface:
  `ClassFile`

public static sealed interface ClassFile.AttributeMapperOption extends ClassFile.Option
The option describing user-defined attributes for parsing `class` files. The default does not recognize any user-defined attribute.

An `AttributeMapperOption` contains a function that maps an attribute name to a user attribute mapper. The function may return `null` if it does not recognize an attribute name. The returned mapper must ensure its `name()` is equivalent to the `stringValue()` of the input `Utf8Entry`.

The mapping function in this attribute has lower priority than mappers in `Attributes`, so it is impossible to override built-in attributes with this option. If an attribute is not recognized by any mapper in `Attributes` and is not assigned a mapper, or recognized, by this option, that attribute will be modeled by an `UnknownAttribute`.

Since:
  24
See Also:
  - `AttributeMapper`
  - `CustomAttribute`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Function<Utf8Entry, AttributeMapper<?>>`
  `attributeMapper()`
  Returns the function mapping attribute names to attribute mappers.
  `static ClassFile.AttributeMapperOption`
  `of(Function<Utf8Entry, AttributeMapper<?>> attributeMapper)`
  Returns an option describing user-defined attributes for parsing.

- ## Method Details

  - ### of

    static ClassFile.AttributeMapperOption of(Function<Utf8Entry, AttributeMapper<?>> attributeMapper)
    Returns an option describing user-defined attributes for parsing.
    Parameters:
      `attributeMapper` - a function mapping attribute names to attribute mappers
    Returns:
      an option describing user-defined attributes for parsing

  - ### attributeMapper

    Function<Utf8Entry, AttributeMapper<?>> attributeMapper()
    Returns the function mapping attribute names to attribute mappers.
    Returns:
      the function mapping attribute names to attribute mappers