Interface MemberDetails

All Superinterfaces:
AnnotationTarget
All Known Subinterfaces:
FieldDetails, MethodDetails, MutableMemberDetails, RecordComponentDetails
All Known Implementing Classes:
DynamicFieldDetails, JdkFieldDetails, JdkMethodDetails, JdkRecordComponentDetails

public interface MemberDetails extends AnnotationTarget
Models a member in a class while processing annotations.
API Note:
This can be a virtual member, meaning there is no physical member in the declaring type (which itself might be virtual)
  • Method Details

    • getName

      String getName()
      The name of the member. This would be the name of the method or field.
      Specified by:
      getName in interface AnnotationTarget
    • getType

      TypeDetails getType()
      The member type. May be null
      Returns:
      Returns one of:
      • for a field, the field type
      • for a getter method, the return type
      • for a setter method, the argument type
      • otherwise, null
    • getContainer

      default ClassDetails getContainer(ModelsContext modelsContext)
      Description copied from interface: AnnotationTarget
      Get the ClassDetails for the class which is the "container" for this target.
      • For a member (org.hib.Thing#id), this will be the declaring type (org.hib.Thing).
      • For a class (org.hib.Thing), this will be the ClassDetails for its package (org.hib.package-info)
      • For a package (org.hib.package-info), this will be the ClassDetails for the containing package (org.package-info)
      Specified by:
      getContainer in interface AnnotationTarget
    • getAssociatedType

      default TypeDetails getAssociatedType()
      For plural members, the "element type"; otherwise, the member's type
    • getElementType

      default TypeDetails getElementType()
      Get the plural element type for this member. If the member does not have a type or the member is not plural, a null is returned.

      For arrays, lists and sets the element type is returned.

      For maps, the value type is returned.

    • getMapKeyType

      default TypeDetails getMapKeyType()
      Get the map key type for this member. If the member does not have a type or the member is not a map, a null is returned.
    • getDeclaringType

      ClassDetails getDeclaringType()
      The class which declares this member
    • isPlural

      boolean isPlural()
      For member's with an associated type, whether that type considered plural.
      Returns:
      true When the member has a type and that type is an array or a Map or Collection inheritor
    • isArray

      boolean isArray()
    • getModifiers

      int getModifiers()
      Access to the member modifier flags.
      See Also:
    • getVisibility

      default MemberDetails.Visibility getVisibility()
      Get the member's visibility
    • isStatic

      default boolean isStatic()
      Whether the member is static
    • isSynthetic

      default boolean isSynthetic()
      Whether the member is synthetic
    • isFinal

      default boolean isFinal()
    • isField

      default boolean isField()
      Whether the member is a field.
      Returns:
      true indicates the member is a field; false indicates it is a method.
    • isPersistable

      boolean isPersistable()
      Can this member be a persistent attribute
    • resolveAttributeName

      String resolveAttributeName()
      For members potentially representing attributes based on naming patterns, determine the attribute name. Return null if the name does not match the pattern for an attribute name.
      Returns:
      The potential attribute name, or null.
      API Note:
      For a field, this will be the name of the field; for a method, this will be the name as determined by the Java Bean naming pattern.
    • toJavaMember

      Member toJavaMember()
      Access to the underlying Member. May return null. May throw an exception.
      Returns:
      The underlying member, or null if there is no underlying member.
      Throws:
      RuntimeException - If there is expected to be a member, but it cannot be located.
    • toJavaMember

      Member toJavaMember(Class<?> declaringClass, ClassLoading classLoading, ModelsContext modelContext)
    • resolveRelativeType

      default TypeDetails resolveRelativeType(TypeVariableScope container)
      Determine the type of the member relative to the given container type.

      For example, given

       class Thing<T extends Number> {
           T id;
       }
       class SubThing extends Thing<Integer> {
           ...
       }
       
      Accessing the id member relative to Thing simply returns the type variable T. However, asking the id member for its type relative to SubThing will report Integer.
      Throws:
      IllegalStateException - If called on a member other than a field, getter, setter or record component.
      API Note:
      It is only valid to call this on members which have a type, i.e. fields, getters, setters and record components.
    • resolveRelativeAssociatedType

      default TypeDetails resolveRelativeAssociatedType(TypeVariableScope container)
      See Also:
    • resolveRelativeClassType

      default ClassBasedTypeDetails resolveRelativeClassType(TypeVariableScope container)
      Determine the concrete class of the member relative to the given container type.

      Similar to resolveRelativeType(TypeVariableScope), but fully resolving the result into the concrete class.

    • asMemberDetails

      default MemberDetails asMemberDetails()
      Description copied from interface: AnnotationTarget
      Safe cast method for cases when the target is a field, method or record component.
      Specified by:
      asMemberDetails in interface AnnotationTarget
    • asAnnotationDescriptor

      default <A extends Annotation> AnnotationDescriptor<A> asAnnotationDescriptor()
      Description copied from interface: AnnotationTarget
      Safe cast method for cases when the target is an annotation.
      Specified by:
      asAnnotationDescriptor in interface AnnotationTarget
    • asClassDetails

      default ClassDetails asClassDetails()
      Description copied from interface: AnnotationTarget
      Safe cast method for cases when the target is a class.
      Specified by:
      asClassDetails in interface AnnotationTarget