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 Details

    • MethodScope

      protected MethodScope(com.fasterxml.classmate.members.ResolvedMethod method, MemberScope.DeclarationDetails declarationDetails, com.github.victools.jsonschema.generator.MemberScope.OverrideDetails overrideDetails, TypeContext context)
      Constructor.
      Parameters:
      method - targeted method
      declarationDetails - basic details regarding the declaration context
      overrideDetails - augmenting details (e.g., overridden type, name, or container item index)
      context - the overall type resolution context
  • Method Details

    • 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 class MemberScope<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:
    • 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 class MemberScope<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:
    • asFakeContainerItemScope

      public MethodScope asFakeContainerItemScope()
      Description copied from class: MemberScope
      Create another instance for this field or method and context, representing its field/method return type's container item type.
      Overrides:
      asFakeContainerItemScope in class MemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
      Returns:
      new instance with the container item type as override (or an identical copy if this is not a container type)
      See Also:
    • isVoid

      public boolean isVoid()
      Indicating whether the method is declared as void, 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:
    • getAnnotation

      public <A extends Annotation> A getAnnotation(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
      Return the annotation of the given type on the method or its return type, if such an annotation is present.
      Overrides:
      getAnnotation in class MemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
      Type Parameters:
      A - type of annotation to look-up
      Parameters:
      annotationClass - annotation class to look up instance on member for
      considerOtherAnnotation - check whether some other annotation should also be checked for holding an instance of the target annotation
      Returns:
      annotation instance (or null if no annotation of the given type is present
    • getContainerItemAnnotation

      public <A extends Annotation> A getContainerItemAnnotation(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
      Description copied from class: MemberScope
      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.
      Specified by:
      getContainerItemAnnotation in class MemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
      Type Parameters:
      A - type of annotation
      Parameters:
      annotationClass - type of annotation
      considerOtherAnnotation - check whether some other annotation should also be checked for holding an instance of the target annotation
      Returns:
      annotation instance (or null if no annotation of the given type is present)
    • getAnnotationConsideringFieldAndGetter

      public <A extends Annotation> A getAnnotationConsideringFieldAndGetter(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
      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.
      Additionally, also consider annotations on annotations, if the given predicate indicates another annotation as eligible for holding the target.
      Specified by:
      getAnnotationConsideringFieldAndGetter in class MemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
      Type Parameters:
      A - type of annotation
      Parameters:
      annotationClass - type of annotation
      considerOtherAnnotation - check whether some other annotation should also be checked for holding an instance of the target annotation
      Returns:
      annotation instance (or null if no annotation of the given type is present)
    • getContainerItemAnnotationConsideringFieldAndGetter

      public <A extends Annotation> A getContainerItemAnnotationConsideringFieldAndGetter(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
      Description copied from class: MemberScope
      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.
      Specified by:
      getContainerItemAnnotationConsideringFieldAndGetter in class MemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
      Type Parameters:
      A - type of annotation
      Parameters:
      annotationClass - type of annotation
      considerOtherAnnotation - check whether some other annotation should also be checked for holding an instance of the target annotation
      Returns:
      annotation instance (or null if no annotation of the given type is present)
    • doGetSchemaPropertyName

      protected String doGetSchemaPropertyName()
      Returns the name to be used to reference this method in its parent's "properties".
      Specified by:
      doGetSchemaPropertyName in class MemberScope<com.fasterxml.classmate.members.ResolvedMethod,Method>
      Returns:
      the (potentially overridden) name of the method followed by its argument types in parentheses
      See Also: