Class MemberScope<M extends com.fasterxml.classmate.members.ResolvedMember<T>,​T extends Member>

  • Type Parameters:
    M - type of member in scope (i.e. ResolvedField or ResolvedMethod).
    T - type of java/reflection member in scope (i.e. FIeld or Nethod
    Direct Known Subclasses:
    FieldScope, MethodScope

    public abstract class MemberScope<M extends com.fasterxml.classmate.members.ResolvedMember<T>,​T extends Member>
    extends Object
    Representation of a single introspected field or method.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected MemberScope​(M member, com.fasterxml.classmate.ResolvedType overriddenType, String overriddenName, com.fasterxml.classmate.ResolvedTypeWithMembers declaringTypeMembers, TypeContext context)
      Constructor.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      <A extends Annotation>
      A
      getAnnotation​(Class<A> annotationClass)
      Return the annotation of the given type on the member, if such an annotation is present.
      abstract <A extends Annotation>
      A
      getAnnotationConsideringFieldAndGetter​(Class<A> annotationClass)
      Return the annotation of the given type on the member, if such an annotation is present on either the field or its getter.
      com.fasterxml.classmate.ResolvedType getContainerItemType()
      Identify the element/item type of the given ""array"".
      TypeContext getContext()
      Getter for the overall type resolution context.
      String getDeclaredName()
      Returns the member's name as specified in the declaring class.
      com.fasterxml.classmate.ResolvedType getDeclaredType()
      Returns the type declared as the field's or method return value's type.
      com.fasterxml.classmate.ResolvedType getDeclaringType()
      Returns the member's declaring type.
      com.fasterxml.classmate.ResolvedTypeWithMembers getDeclaringTypeMembers()
      Getter for the collection of the member's declaring type's (other) fields and methods.
      String getFullTypeDescription()
      Constructing a string that fully represents this member's type (including possible type parameters and their actual types).
      M getMember()
      Getter for the represented field or method.
      String getName()
      Returns name of this member.
      String getOverriddenName()
      Returns the member's overridden name.
      com.fasterxml.classmate.ResolvedType getOverriddenType()
      Returns the overridden type of the field or method's return value.
      T getRawMember()
      Returns the JDK object that represents member.
      abstract String getSchemaPropertyName()
      Returns the name to be used to reference this member in its parent's "properties".
      String getSimpleTypeDescription()
      Constructing a string that represents this member's type (including possible type parameters and their actual types).
      com.fasterxml.classmate.ResolvedType getType()
      Returns type of this member; if it has one, for methods this is the return type and for fields their field type.
      boolean isContainerType()
      Determine whether this member's type should be treated as ""array"" in the generated schema.
      boolean isFinal()
      Indicates whether the member has the final keyword.
      boolean isPrivate()
      Indicates whether the member is of private visibility.
      boolean isProtected()
      Indicates whether the member is of protected visibility.
      boolean isPublic()
      Indicates whether the member is of public visibility.
      boolean isStatic()
      Indicates whether the member has the static keyword.
      String toString()  
      abstract MemberScope<M,​T> withOverriddenName​(String overriddenName)
      Create another instance for this field or method and context, but overriding the declared field/method name with the given one.
      abstract MemberScope<M,​T> withOverriddenType​(com.fasterxml.classmate.ResolvedType overriddenType)
      Create another instance for this field or method and context, but overriding the declared field/method return type with the given one.
    • Constructor Detail

      • MemberScope

        protected MemberScope​(M member,
                              com.fasterxml.classmate.ResolvedType overriddenType,
                              String overriddenName,
                              com.fasterxml.classmate.ResolvedTypeWithMembers declaringTypeMembers,
                              TypeContext context)
        Constructor.
        Parameters:
        member - targeted field or method
        overriddenType - alternative type for this field or method's return value
        overriddenName - alternative name for this field or method
        declaringTypeMembers - collection of the declaring type's (other) fields and methods
        context - the overall type resolution context
    • Method Detail

      • withOverriddenType

        public abstract MemberScope<M,​T> withOverriddenType​(com.fasterxml.classmate.ResolvedType overriddenType)
        Create another instance for this field or method and context, but overriding the declared field/method return type with the given one.
        Parameters:
        overriddenType - alternative type for this field or method return value (overriding the declared type)
        Returns:
        new instance with the given type override
        See Also:
        getDeclaredType(), getOverriddenType()
      • withOverriddenName

        public abstract MemberScope<M,​T> withOverriddenName​(String overriddenName)
        Create another instance for this field or method and context, but overriding the declared field/method name with the given one.
        Parameters:
        overriddenName - alternative name for this field or method
        Returns:
        new instance with the given name override
        See Also:
        getDeclaredType(), getOverriddenType()
      • getMember

        public M getMember()
        Getter for the represented field or method.
        Returns:
        represented field or method
      • getDeclaringTypeMembers

        public com.fasterxml.classmate.ResolvedTypeWithMembers getDeclaringTypeMembers()
        Getter for the collection of the member's declaring type's (other) fields and methods.
        Returns:
        declaring type's fields and methods
      • getContext

        public TypeContext getContext()
        Getter for the overall type resolution context.
        Returns:
        type resolution context
      • getDeclaredType

        public com.fasterxml.classmate.ResolvedType getDeclaredType()
        Returns the type declared as the field's or method return value's type.
        Returns:
        declared type
        See Also:
        getType()
      • getOverriddenType

        public com.fasterxml.classmate.ResolvedType getOverriddenType()
        Returns the overridden type of the field or method's return value.
        Returns:
        overridden type (or null if no override applies)
        See Also:
        getType()
      • getType

        public com.fasterxml.classmate.ResolvedType getType()
        Returns type of this member; if it has one, for methods this is the return type and for fields their field type.
        Returns:
        method return type or field type
        See Also:
        getDeclaredType(), getOverriddenType()
      • getDeclaredName

        public String getDeclaredName()
        Returns the member's name as specified in the declaring class.
        Returns:
        declared method/field name
        See Also:
        getName()
      • getOverriddenName

        public String getOverriddenName()
        Returns the member's overridden name.
        Returns:
        overridden name (or null if no override applies)
        See Also:
        getName()
      • getDeclaringType

        public final com.fasterxml.classmate.ResolvedType getDeclaringType()
        Returns the member's declaring type.
        Returns:
        declaring type
      • getRawMember

        public T getRawMember()
        Returns the JDK object that represents member.
        Returns:
        raw member
      • isStatic

        public boolean isStatic()
        Indicates whether the member has the static keyword.
        Returns:
        whether member is static
      • isFinal

        public boolean isFinal()
        Indicates whether the member has the final keyword.
        Returns:
        whether member is final
      • isPrivate

        public boolean isPrivate()
        Indicates whether the member is of private visibility.
        Returns:
        whether member is private
      • isProtected

        public boolean isProtected()
        Indicates whether the member is of protected visibility.
        Returns:
        whether member is protected
      • isPublic

        public boolean isPublic()
        Indicates whether the member is of public visibility.
        Returns:
        whether member is public
      • getAnnotation

        public <A extends Annotation> A getAnnotation​(Class<A> annotationClass)
        Return the annotation of the given type on the member, if such an annotation is present.
        Type Parameters:
        A - type of annotation to look-up
        Parameters:
        annotationClass - annotation class to look up instance on member for
        Returns:
        annotation instance (or null if no annotation of the given type is present
      • getAnnotationConsideringFieldAndGetter

        public abstract <A extends Annotation> A getAnnotationConsideringFieldAndGetter​(Class<A> annotationClass)
        Return the annotation of the given type on the member, if such an annotation is present on either the field or its getter.
        Type Parameters:
        A - type of annotation
        Parameters:
        annotationClass - type of annotation
        Returns:
        annotation instance (or null if no annotation of the given type is present)
      • isContainerType

        public boolean isContainerType()
        Determine whether this member's type should be treated as ""array"" in the generated schema.
        This is equivalent to calling: scope.getContext().isContainerType(scope.getType())
        Returns:
        whether this member's type is an array or sub type of Collection
      • getContainerItemType

        public com.fasterxml.classmate.ResolvedType getContainerItemType()
        Identify the element/item type of the given ""array"".
        This is equivalent to calling: scope.getContext().getContainerItemType(scope.getType())
        Returns:
        type of elements/items
      • getSimpleTypeDescription

        public String getSimpleTypeDescription()
        Constructing a string that represents this member's type (including possible type parameters and their actual types).
        This is equivalent to calling: scope.getContext().getSimpleTypeDescription(scope.getType())
        Returns:
        resulting string
        See Also:
        getType(), TypeContext.getSimpleTypeDescription(ResolvedType)
      • getFullTypeDescription

        public String getFullTypeDescription()
        Constructing a string that fully represents this member's type (including possible type parameters and their actual types).
        This is equivalent to calling: scope.getContext().getFullTypeDescription(scope.getType())
        Returns:
        resulting string
        See Also:
        getType(), TypeContext.getFullTypeDescription(ResolvedType)
      • getSchemaPropertyName

        public abstract String getSchemaPropertyName()
        Returns the name to be used to reference this member in its parent's "properties".
        Returns:
        member's name in parent "properties"