Class MemberScope<M extends com.fasterxml.classmate.members.ResolvedMember<T>,T extends Member>
- java.lang.Object
-
- com.github.victools.jsonschema.generator.TypeScope
-
- com.github.victools.jsonschema.generator.MemberScope<M,T>
-
- Type Parameters:
M- type of member in scope (i.e.ResolvedFieldorResolvedMethod).T- type of java/reflection member in scope (i.e.FieldorMethod
- Direct Known Subclasses:
FieldScope,MethodScope
public abstract class MemberScope<M extends com.fasterxml.classmate.members.ResolvedMember<T>,T extends Member> extends TypeScope
Representation of a single introspected field or method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMemberScope.DeclarationDetails
-
Constructor Summary
Constructors Modifier Constructor Description protectedMemberScope(M member, MemberScope.DeclarationDetails declarationDetails, com.github.victools.jsonschema.generator.MemberScope.OverrideDetails overrideDetails, TypeContext context)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description MemberScope<M,T>asFakeContainerItemScope()Create another instance for this field or method and context, representing its field/method return type's container item type.MemberScope<M,T>asFakeContainerItemScope(Class<?> referenceType, int containerItemIndex)Create another instance for this field or method and context, representing its field/method return type's container item type.protected abstract StringdoGetSchemaPropertyName()Returns the name to be used to reference this member in its parent's "properties".<A extends Annotation>
AgetAnnotation(Class<A> annotationClass)Return the annotation of the given type on the member, if such an annotation is present.<A extends Annotation>
AgetAnnotation(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)Return the annotation of the given type on the member, if such an annotation is present.<A extends Annotation>
AgetAnnotationConsideringFieldAndGetter(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.abstract <A extends Annotation>
AgetAnnotationConsideringFieldAndGetter(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)Return the annotation of the given type on the member, if such an annotation is present on either the field or its getter.<A extends Annotation>
AgetAnnotationConsideringFieldAndGetterIfSupported(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 and this is not afake container item scope.<A extends Annotation>
AgetAnnotationConsideringFieldAndGetterIfSupported(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)Return the annotation of the given type on the member, if such an annotation is present on either the field or its getter and this is not afake container item scope.<A extends Annotation>
AgetContainerItemAnnotation(Class<A> annotationClass)Return the annotation of the given type on the member's container item (i.e.abstract <A extends Annotation>
AgetContainerItemAnnotation(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)Return the annotation of the given type on the member's container item (i.e.<A extends Annotation>
AgetContainerItemAnnotationConsideringFieldAndGetter(Class<A> annotationClass)Return the annotation of the given type on the member's container item (i.e.abstract <A extends Annotation>
AgetContainerItemAnnotationConsideringFieldAndGetter(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)Return the annotation of the given type on the member's container item (i.e.<A extends Annotation>
AgetContainerItemAnnotationConsideringFieldAndGetterIfSupported(Class<A> annotationClass)Return the annotation of the given type on the member's container item (i.e.<A extends Annotation>
AgetContainerItemAnnotationConsideringFieldAndGetterIfSupported(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)Return the annotation of the given type on the member's container item (i.e.MemberScope.DeclarationDetailsgetDeclarationDetails()Getter for additional declaration context information.StringgetDeclaredName()Returns the member's name as specified in the declaring class.com.fasterxml.classmate.ResolvedTypegetDeclaredType()Returns the type declared as the field's or method return value's type.com.fasterxml.classmate.ResolvedTypegetDeclaringType()Returns the member's declaring type.com.fasterxml.classmate.ResolvedTypeWithMembersgetDeclaringTypeMembers()Getter for the collection of the member's declaring type's (other) fields and methods.protected IntegergetFakeContainerItemIndex()Getter for thefakeContainerItemIndex(may be null).MgetMember()Getter for the represented field or method.StringgetName()Returns name of this member.StringgetOverriddenName()Returns the member's overridden name.com.fasterxml.classmate.ResolvedTypegetOverriddenType()Returns the overridden type of the field or method's return value.TgetRawMember()Returns the JDK object that represents member.StringgetSchemaPropertyName()Returns the name to be used to reference this member in its parent's "properties".booleanisFakeContainerItemScope()Check whether this field/method scope represents only the container item type of the actual field/method.booleanisFinal()Indicates whether the member has thefinalkeyword.booleanisPrivate()Indicates whether the member is ofprivatevisibility.booleanisProtected()Indicates whether the member is ofprotectedvisibility.booleanisPublic()Indicates whether the member is ofpublicvisibility.booleanisStatic()Indicates whether the member has thestatickeyword.StringtoString()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.-
Methods inherited from class com.github.victools.jsonschema.generator.TypeScope
getContainerItemType, getContext, getFullTypeDescription, getSimpleTypeDescription, getType, getTypeParameterFor, isContainerType
-
-
-
-
Constructor Detail
-
MemberScope
protected MemberScope(M member, MemberScope.DeclarationDetails declarationDetails, com.github.victools.jsonschema.generator.MemberScope.OverrideDetails overrideDetails, TypeContext context)
Constructor.- Parameters:
member- targeted field or methoddeclarationDetails- basic details regarding the declaration contextoverrideDetails- augmenting details (e.g., overridden type, name, or container item index)context- the overall type resolution context
-
-
Method Detail
-
getFakeContainerItemIndex
protected Integer getFakeContainerItemIndex()
Getter for thefakeContainerItemIndex(may be null).- Returns:
- index of the container item on the generic field/method scope's declared type (e.g., in case of a List, it is 0)
- See Also:
isFakeContainerItemScope()
-
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()
-
asFakeContainerItemScope
public MemberScope<M,T> asFakeContainerItemScope()
Create another instance for this field or method and context, representing its field/method return type's container item type.- Returns:
- new instance with the container item type as override (or an identical copy if this is not a container type)
- See Also:
withOverriddenType(ResolvedType),TypeScope.getContainerItemType(),isFakeContainerItemScope()
-
asFakeContainerItemScope
public MemberScope<M,T> asFakeContainerItemScope(Class<?> referenceType, int containerItemIndex)
Create another instance for this field or method and context, representing its field/method return type's container item type.- Parameters:
referenceType- the generic "container type" from which to extract the "container item type"containerItemIndex- index of the container item on the generic field/method scope's declared type (e.g., in case of a List, it is 0)- Returns:
- new instance with the container item type as override (or an identical copy if this is not a container type)
- See Also:
withOverriddenType(ResolvedType),TypeScope.getContainerItemType(),isFakeContainerItemScope()
-
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
-
getDeclarationDetails
public MemberScope.DeclarationDetails getDeclarationDetails()
Getter for additional declaration context information.- Returns:
- wrapper for the schema target type and declaring type's field and methods
-
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
-
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:
TypeScope.getType()
-
getOverriddenType
public com.fasterxml.classmate.ResolvedType getOverriddenType()
Returns the overridden type of the field or method's return value.- Returns:
- overridden type (or
nullif no override applies) - See Also:
TypeScope.getType()
-
isFakeContainerItemScope
public boolean isFakeContainerItemScope()
Check whether this field/method scope represents only the container item type of the actual field/method.- Returns:
- whether this is not the actual field/method but a representation of its container item type
-
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
nullif no override applies) - See Also:
getName()
-
getName
public String getName()
Returns name of this member.- Returns:
- method/field name
- See Also:
getDeclaredName(),getOverriddenName()
-
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 thestatickeyword.- Returns:
- whether member is static
-
isFinal
public boolean isFinal()
Indicates whether the member has thefinalkeyword.- Returns:
- whether member is final
-
isPrivate
public boolean isPrivate()
Indicates whether the member is ofprivatevisibility.- Returns:
- whether member is private
-
isProtected
public boolean isProtected()
Indicates whether the member is ofprotectedvisibility.- Returns:
- whether member is protected
-
isPublic
public boolean isPublic()
Indicates whether the member is ofpublicvisibility.- 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.
Using this method is equivalent to invokinggetAnnotation(Class, Predicate)with the second parameter always returningfalse.- Type Parameters:
A- type of annotation to look-up- Parameters:
annotationClass- annotation class to look up instance on member for- Returns:
- annotation instance (or
nullif no annotation of the given type is present
-
getAnnotation
public <A extends Annotation> A getAnnotation(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
Return the annotation of the given type on the member, if such an annotation is present.
Additionally, also consider annotations on annotations, if the given predicate indicates another annotation as eligible for holding the target.- Type Parameters:
A- type of annotation to look-up- Parameters:
annotationClass- annotation class to look up instance on member forconsiderOtherAnnotation- check whether some other annotation should also be checked for holding an instance of the target annotation- Returns:
- annotation instance (or
nullif no annotation of the given type is present - Since:
- 4.30.0
-
getContainerItemAnnotation
public <A extends Annotation> A getContainerItemAnnotation(Class<A> annotationClass)
Return the annotation of the given type on the member's container item (i.e. first type parameter if there is one), 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
nullif no annotation of the given type is present)
-
getContainerItemAnnotation
public abstract <A extends Annotation> A getContainerItemAnnotation(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
Return the annotation of the given type on the member's container item (i.e. first type parameter if there is one), if such an annotation is present on either the field or its getter.
Additionally, also consider annotations on annotations, if the given predicate indicates another annotation as eligible for holding the target.- Type Parameters:
A- type of annotation- Parameters:
annotationClass- type of annotationconsiderOtherAnnotation- check whether some other annotation should also be checked for holding an instance of the target annotation- Returns:
- annotation instance (or
nullif no annotation of the given type is present) - Since:
- 4.30.0
-
getAnnotationConsideringFieldAndGetter
public <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
nullif no annotation of the given type is present)
-
getAnnotationConsideringFieldAndGetter
public abstract <A extends Annotation> A getAnnotationConsideringFieldAndGetter(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
Return the annotation of the given type on the member, if such an annotation is present on either the field or its getter.
Additionally, also consider annotations on annotations, if the given predicate indicates another annotation as eligible for holding the target.- Type Parameters:
A- type of annotation- Parameters:
annotationClass- type of annotationconsiderOtherAnnotation- check whether some other annotation should also be checked for holding an instance of the target annotation- Returns:
- annotation instance (or
nullif no annotation of the given type is present) - Since:
- 4.30.0
-
getAnnotationConsideringFieldAndGetterIfSupported
public <A extends Annotation> A getAnnotationConsideringFieldAndGetterIfSupported(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 and this is not afake container item scope.- Type Parameters:
A- type of annotation- Parameters:
annotationClass- type of annotation- Returns:
- annotation instance (or
nullif no annotation of the given type is present or the look-up is not supported by default)
-
getAnnotationConsideringFieldAndGetterIfSupported
public <A extends Annotation> A getAnnotationConsideringFieldAndGetterIfSupported(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
Return the annotation of the given type on the member, if such an annotation is present on either the field or its getter and this is not afake container item scope.
Additionally, also consider annotations on annotations, if the given predicate indicates another annotation as eligible for holding the target.- Type Parameters:
A- type of annotation- Parameters:
annotationClass- type of annotationconsiderOtherAnnotation- check whether some other annotation should also be checked for holding an instance of the target annotation- Returns:
- annotation instance (or
nullif no annotation of the given type is present or the look-up is not supported by default) - Since:
- 4.30.0
-
getContainerItemAnnotationConsideringFieldAndGetter
public <A extends Annotation> A getContainerItemAnnotationConsideringFieldAndGetter(Class<A> annotationClass)
Return the annotation of the given type on the member's container item (i.e. single type parameter if there is one), 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
nullif no annotation of the given type is present)
-
getContainerItemAnnotationConsideringFieldAndGetter
public abstract <A extends Annotation> A getContainerItemAnnotationConsideringFieldAndGetter(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
Return the annotation of the given type on the member's container item (i.e. single type parameter if there is one), if such an annotation is present on either the field or its getter.
Additionally, also consider annotations on annotations, if the given predicate indicates another annotation as eligible for holding the target.- Type Parameters:
A- type of annotation- Parameters:
annotationClass- type of annotationconsiderOtherAnnotation- check whether some other annotation should also be checked for holding an instance of the target annotation- Returns:
- annotation instance (or
nullif no annotation of the given type is present) - Since:
- 4.30.0
-
getContainerItemAnnotationConsideringFieldAndGetterIfSupported
public <A extends Annotation> A getContainerItemAnnotationConsideringFieldAndGetterIfSupported(Class<A> annotationClass)
Return the annotation of the given type on the member's container item (i.e. single type parameter if there is one), if such an annotation is present on either the field or its getter and this particular member is either a collection or special generic type (e.g.Optional).- Type Parameters:
A- type of annotation- Parameters:
annotationClass- type of annotation- Returns:
- annotation instance (or
nullif no annotation of the given type is present or this look-up is not supported by default )
-
getContainerItemAnnotationConsideringFieldAndGetterIfSupported
public <A extends Annotation> A getContainerItemAnnotationConsideringFieldAndGetterIfSupported(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
Return the annotation of the given type on the member's container item (i.e. single type parameter if there is one), if such an annotation is present on either the field or its getter and this particular member is either a collection or special generic type (e.g.Optional).
Additionally, also consider annotations on annotations, if the given predicate indicates another annotation as eligible for holding the target.- Type Parameters:
A- type of annotation- Parameters:
annotationClass- type of annotationconsiderOtherAnnotation- check whether some other annotation should also be checked for holding an instance of the target annotation- Returns:
- annotation instance (or
nullif no annotation of the given type is present or this look-up is not supported by default) - Since:
- 4.30.0
-
getSchemaPropertyName
public String getSchemaPropertyName()
Returns the name to be used to reference this member in its parent's "properties".- Returns:
- member's name in parent "properties"
-
doGetSchemaPropertyName
protected abstract String doGetSchemaPropertyName()
Returns the name to be used to reference this member in its parent's "properties".- Returns:
- member's name in parent "properties"
-
-