Interface AttributedElement

All Superinterfaces:
ClassFileElement
All Known Subinterfaces:
ClassModel, CodeAttribute, CodeModel, FieldModel, MethodModel, RecordComponentInfo

public sealed interface AttributedElement extends ClassFileElement permits ClassModel, CodeModel, FieldModel, MethodModel, RecordComponentInfo (not exhaustive)
A ClassFileElement describing an entity that has attributes, such as a class, field, method, code attribute, or record component.
Sealed Class Hierarchy Graph:
Sealed class hierarchy graph for AttributedElementSealed class hierarchy graph for AttributedElement
Since:
24
  • Method Details

    • attributes

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

      default <T extends Attribute<T>> Optional<T> findAttribute(AttributeMapper<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 Attribute<T>> List<T> findAttributes(AttributeMapper<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