Class FieldScope
- java.lang.Object
-
- com.github.victools.jsonschema.generator.TypeScope
-
- com.github.victools.jsonschema.generator.MemberScope<com.fasterxml.classmate.members.ResolvedField,Field>
-
- com.github.victools.jsonschema.generator.FieldScope
-
public class FieldScope extends MemberScope<com.fasterxml.classmate.members.ResolvedField,Field>
Representation of a single introspected field.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FieldScope(com.fasterxml.classmate.members.ResolvedField field, com.fasterxml.classmate.ResolvedType overriddenType, String overriddenName, com.fasterxml.classmate.ResolvedTypeWithMembers declaringTypeMembers, TypeContext context)
Constructor.protected
FieldScope(com.fasterxml.classmate.members.ResolvedField field, com.fasterxml.classmate.ResolvedTypeWithMembers declaringTypeMembers, TypeContext context)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MethodScope
findGetter()
Return the conventional getter method (if one exists).<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.String
getSchemaPropertyName()
Returns the name to be used to reference this field in its parent's "properties".boolean
hasGetter()
Determine whether the field's declaring class contains a matching method starting with "get" or "is".boolean
isTransient()
Indicates whether the field has thetransient
keyword.FieldScope
withOverriddenName(String overriddenName)
Create another instance for this field or method and context, but overriding the declared field/method name with the given one.FieldScope
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, isContainerType
-
-
-
-
Constructor Detail
-
FieldScope
protected FieldScope(com.fasterxml.classmate.members.ResolvedField field, com.fasterxml.classmate.ResolvedTypeWithMembers declaringTypeMembers, TypeContext context)
Constructor.- Parameters:
field
- targeted fielddeclaringTypeMembers
- collection of the declaring type's (other) fields and methodscontext
- the overall type resolution context
-
FieldScope
protected FieldScope(com.fasterxml.classmate.members.ResolvedField field, com.fasterxml.classmate.ResolvedType overriddenType, String overriddenName, com.fasterxml.classmate.ResolvedTypeWithMembers declaringTypeMembers, TypeContext context)
Constructor.- Parameters:
field
- targeted fieldoverriddenType
- alternative type for this fieldoverriddenName
- alternative name for this fielddeclaringTypeMembers
- collection of the declaring type's (other) fields and methodscontext
- the overall type resolution context
-
-
Method Detail
-
withOverriddenType
public FieldScope 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.ResolvedField,Field>
- 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 FieldScope 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.ResolvedField,Field>
- Parameters:
overriddenName
- alternative name for this field or method- Returns:
- new instance with the given name override
- See Also:
MemberScope.getDeclaredType()
,MemberScope.getOverriddenType()
-
getSchemaPropertyName
public String getSchemaPropertyName()
Returns the name to be used to reference this field in its parent's "properties".- Specified by:
getSchemaPropertyName
in classMemberScope<com.fasterxml.classmate.members.ResolvedField,Field>
- Returns:
- the (potentially overridden) name of this field
- See Also:
MemberScope.getName()
-
isTransient
public boolean isTransient()
Indicates whether the field has thetransient
keyword.- Returns:
- whether field is transient
-
findGetter
public MethodScope findGetter()
Return the conventional getter method (if one exists). E.g. for a field named "foo", look-up either "getFoo()" or "isFoo()".- Returns:
- public getter from within the field's declaring class
-
hasGetter
public boolean hasGetter()
Determine whether the field's declaring class contains a matching method starting with "get" or "is".- Returns:
- whether a matching getter exists in the field's declaring class
- See Also:
findGetter()
-
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.ResolvedField,Field>
- 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)
-
-