Interface AttributedElement

All Superinterfaces:
ClassFileElement
All Known Subinterfaces:
ClassModel, CodeAttribute, CodeModel, FieldModel, MethodModel, RecordComponentInfo
All Known Implementing Classes:
AbstractUnboundModel, BoundAttribute.BoundCodeAttribute, BoundRecordComponentInfo, BufferedCodeBuilder.Model, BufferedFieldBuilder.Model, BufferedMethodBuilder.Model, ClassImpl, CodeImpl, FieldImpl, MethodImpl, UnboundAttribute.UnboundRecordComponentInfo

public sealed interface AttributedElement extends ClassFileElement permits ClassModel, CodeModel, FieldModel, MethodModel, RecordComponentInfo, AbstractUnboundModel<E>
A ClassFileElement describing an entity that has attributes, such as a class, field, method, code attribute, or record component.
Since:
22
  • 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