Interface MemberElement

All Superinterfaces:
AnnotatedElement, AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, Described, Element, MutableAnnotationMetadataDelegate<Element>, Named
All Known Subinterfaces:
BeanConstructorElement, BeanFieldElement, BeanMethodElement, ConstructorElement, EnumConstantElement, FieldElement, MethodElement, PropertyElement
All Known Implementing Classes:
GroovyConstructorElement, GroovyEnumConstantElement, GroovyFieldElement, GroovyMethodElement, JavaMethodElement

public interface MemberElement extends Element
A member element is an element that is contained within a ClassElement. The getDeclaringType() method returns the class that declares the element.
Since:
1.0
Author:
graemerocher
  • Method Details

    • getDeclaringType

      ClassElement getDeclaringType()
      Returns:
      The declaring type of the element.
    • getOwningType

      default ClassElement getOwningType()
      The owing type is the type that owns this element. This can differ from getDeclaringType() in the case of inheritance since this method will return the subclass that owners the inherited member, whilst getDeclaringType() will return the super class that declares the type.
      Returns:
      The owning type.
    • getModifiers

      default Set<ElementModifier> getModifiers()
      Specified by:
      getModifiers in interface Element
      Returns:
      The ElementModifier types for this class element
      Since:
      3.0.0
    • isReflectionRequired

      default boolean isReflectionRequired()
      Returns whether this member element will require reflection to invoke or retrieve at runtime.

      This method uses getOwningType() as the calling type for this method.

      Returns:
      Will return true if reflection is required.
      Since:
      3.4.0
    • isReflectionRequired

      default boolean isReflectionRequired(@NonNull @NonNull ClassElement callingType)
      Returns whether this member element will require reflection to invoke or retrieve at runtime.
      Parameters:
      callingType - The calling type
      Returns:
      Will return true if reflection is required.
      Since:
      3.4.0
    • isAccessible

      default boolean isAccessible()
      Returns whether this member element can be invoked or retrieved at runtime. It can be accessible by a simple invocation or a reflection invocation.

      This method uses isReflectionRequired() with a checks if the reflection access is allowed. By checking for ReflectiveAccess annotation.

      Returns:
      Will return true if is accessible.
      Since:
      3.7.0
    • isAccessible

      default boolean isAccessible(@NonNull @NonNull ClassElement callingType, boolean allowReflection)
      Returns whether this member element can be invoked or retrieved at runtime. It can be accessible by a simple invocation

      This method uses isReflectionRequired() with a checks if the reflection access is allowed. By checking for ReflectiveAccess annotation.

      Parameters:
      callingType - The calling type
      allowReflection - If reflection invocation can be used
      Returns:
      Will return true if is accessible.
      Since:
      4.3.0
    • isAccessible

      default boolean isAccessible(@NonNull @NonNull ClassElement callingType)
      Returns whether this member element can be invoked or retrieved at runtime. It can be accessible by a simple invocation or a reflection invocation.

      This method uses isReflectionRequired() with a checks if the reflection access is allowed. By checking for ReflectiveAccess annotation.

      Parameters:
      callingType - The calling type
      Returns:
      Will return true if is accessible.
      Since:
      3.7.0
    • withAnnotationMetadata

      default MemberElement withAnnotationMetadata(AnnotationMetadata annotationMetadata)
      Description copied from interface: Element
      Copies this element and overrides its annotations.
      Specified by:
      withAnnotationMetadata in interface Element
      Parameters:
      annotationMetadata - The annotation metadata
      Returns:
      A new element
    • hides

      default boolean hides(@NonNull @NonNull MemberElement hidden)
      Checks if this member element hides another.
      Parameters:
      hidden - The possibly hidden element
      Returns:
      true if this member element hides passed field element
      Since:
      4.0.0