Interface AttributedElement

All Superinterfaces:
ClassFileElementPREVIEW
All Known Subinterfaces:
ClassModelPREVIEW, CodeAttributePREVIEW, CodeModelPREVIEW, FieldModelPREVIEW, MethodModelPREVIEW, RecordComponentInfoPREVIEW

public sealed interface AttributedElement extends ClassFileElementPREVIEW permits ClassModelPREVIEW, CodeModelPREVIEW, FieldModelPREVIEW, MethodModelPREVIEW, RecordComponentInfoPREVIEW (not exhaustive)
AttributedElement is a preview API of the Java platform.
Programs can only use AttributedElement when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A ClassFileElementPREVIEW describing an entity that has attributes, such as a class, field, method, code attribute, or record component.
Since:
22
  • Method Details

    • attributes

      List<AttributePREVIEW<?>> attributes()
      Returns the attributes of this element.
      Returns:
      the attributes of this element
    • findAttribute

      default <T extends AttributePREVIEW<T>> Optional<T> findAttribute(AttributeMapperPREVIEW<T> attr)
      Finds an attribute by name.
      Type Parameters:
      T - the type of the attribute
      Parameters:
      attr - the attribute mapper
      Returns:
      the attribute, or an empty Optional if the attribute is not present
    • findAttributes

      default <T extends AttributePREVIEW<T>> List<T> findAttributes(AttributeMapperPREVIEW<T> attr)
      Finds one or more attributes by name.
      Type Parameters:
      T - the type of the attribute
      Parameters:
      attr - the attribute mapper
      Returns:
      the attributes, or an empty List if the attribute is not present