Class MethodScope
- java.lang.Object
-
- com.github.victools.jsonschema.generator.TypeScope
-
- com.github.victools.jsonschema.generator.MemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
-
- com.github.victools.jsonschema.generator.MethodScope
-
public class MethodScope extends MemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
Representation of a single introspected method.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MethodScope(com.fasterxml.classmate.members.ResolvedMethod method, com.fasterxml.classmate.ResolvedType overriddenType, String overriddenName, com.fasterxml.classmate.ResolvedTypeWithMembers declaringTypeMembers, TypeContext context)
Constructor.protected
MethodScope(com.fasterxml.classmate.members.ResolvedMethod method, com.fasterxml.classmate.ResolvedTypeWithMembers declaringTypeMembers, TypeContext context)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FieldScope
findGetterField()
Look-up the field associated with this method if it is deemed to be a getter by convention.<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.int
getArgumentCount()
Returns the number of arguments this method has.List<com.fasterxml.classmate.ResolvedType>
getArgumentTypes()
Returns the list of types of this method's arguments.String
getSchemaPropertyName()
Returns the name to be used to reference this method in its parent's "properties".boolean
isGetter()
Determine whether the method's name matches the getter naming convention ("getFoo()"/"isFoo()") and a respective field ("foo") exists.boolean
isVoid()
Indicating whether the method is declared asvoid
, i.e.MethodScope
withOverriddenName(String overriddenName)
Create another instance for this field or method and context, but overriding the declared field/method name with the given one.MethodScope
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.MemberScope
getAnnotation, getDeclaredName, getDeclaredType, getDeclaringType, getDeclaringTypeMembers, getMember, getName, getOverriddenName, getOverriddenType, getRawMember, isFinal, isPrivate, isProtected, isPublic, isStatic, toString
-
Methods inherited from class com.github.victools.jsonschema.generator.TypeScope
getContainerItemType, getContext, getFullTypeDescription, getSimpleTypeDescription, getType, getTypeParameterFor, isContainerType
-
-
-
-
Constructor Detail
-
MethodScope
protected MethodScope(com.fasterxml.classmate.members.ResolvedMethod method, com.fasterxml.classmate.ResolvedTypeWithMembers declaringTypeMembers, TypeContext context)
Constructor.- Parameters:
method
- targeted methoddeclaringTypeMembers
- collection of the declaring type's fields and (other) methodscontext
- the overall type resolution context
-
MethodScope
protected MethodScope(com.fasterxml.classmate.members.ResolvedMethod method, com.fasterxml.classmate.ResolvedType overriddenType, String overriddenName, com.fasterxml.classmate.ResolvedTypeWithMembers declaringTypeMembers, TypeContext context)
Constructor.- Parameters:
method
- targeted methodoverriddenType
- alternative type for this method's return valueoverriddenName
- alternative name for this methoddeclaringTypeMembers
- collection of the declaring type's fields and (other) methodscontext
- the overall type resolution context
-
-
Method Detail
-
withOverriddenType
public MethodScope withOverriddenType(com.fasterxml.classmate.ResolvedType overriddenType)
Description copied from class:MemberScope
Create another instance for this field or method and context, but overriding the declared field/method return type with the given one.- Specified by:
withOverriddenType
in classMemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
- 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:
MemberScope.getDeclaredType()
,MemberScope.getOverriddenType()
-
withOverriddenName
public MethodScope withOverriddenName(String overriddenName)
Description copied from class:MemberScope
Create another instance for this field or method and context, but overriding the declared field/method name with the given one.- Specified by:
withOverriddenName
in classMemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
- Parameters:
overriddenName
- alternative name for this field or method- Returns:
- new instance with the given name override
- See Also:
MemberScope.getDeclaredType()
,MemberScope.getOverriddenType()
-
isVoid
public boolean isVoid()
Indicating whether the method is declared asvoid
, i.e. has no return value.- Returns:
- whether method has no return value
-
getArgumentCount
public int getArgumentCount()
Returns the number of arguments this method has.- Returns:
- number of arguments
-
getArgumentTypes
public List<com.fasterxml.classmate.ResolvedType> getArgumentTypes()
Returns the list of types of this method's arguments.- Returns:
- argument types
-
findGetterField
public FieldScope findGetterField()
Look-up the field associated with this method if it is deemed to be a getter by convention.- Returns:
- associated field
-
isGetter
public boolean isGetter()
Determine whether the method's name matches the getter naming convention ("getFoo()"/"isFoo()") and a respective field ("foo") exists.- Returns:
- whether method name starts with "get"/"is" and rest matches name of field in declaring class
- See Also:
findGetterField()
-
getAnnotationConsideringFieldAndGetter
public <A extends Annotation> A getAnnotationConsideringFieldAndGetter(Class<A> annotationClass)
Description copied from class:MemberScope
Return the annotation of the given type on the member, if such an annotation is present on either the field or its getter.- Specified by:
getAnnotationConsideringFieldAndGetter
in classMemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
- 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)
-
getSchemaPropertyName
public String getSchemaPropertyName()
Returns the name to be used to reference this method in its parent's "properties".- Specified by:
getSchemaPropertyName
in classMemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
- Returns:
- the (potentially overridden) name of the method followed by its argument types in parentheses
- See Also:
MemberScope.getName()
,TypeContext.getMethodPropertyArgumentTypeDescription(ResolvedType)
-
-