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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.github.victools.jsonschema.generator.MemberScope
MemberScope.DeclarationDetails
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFieldScope(com.fasterxml.classmate.members.ResolvedField field, MemberScope.DeclarationDetails declarationDetails, com.github.victools.jsonschema.generator.MemberScope.OverrideDetails overrideDetails, TypeContext context)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FieldScopeasFakeContainerItemScope()Create another instance for this field or method and context, representing its field/method return type's container item type.protected StringdoGetSchemaPropertyName()Returns the name to be used to reference this field in its parent's "properties".MethodScopefindGetter()Return the conventional getter method (if one exists).<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>
AgetContainerItemAnnotation(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.<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. single type parameter if there is one), if such an annotation is present on either the field or its getter.booleanhasGetter()Determine whether the field's declaring class contains a matching method starting with "get" or "is".booleanisTransient()Indicates whether the field has thetransientkeyword.FieldScopewithOverriddenName(String overriddenName)Create another instance for this field or method and context, but overriding the declared field/method name with the given one.FieldScopewithOverriddenType(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
asFakeContainerItemScope, getAnnotation, getAnnotation, getAnnotationConsideringFieldAndGetter, getAnnotationConsideringFieldAndGetterIfSupported, getAnnotationConsideringFieldAndGetterIfSupported, getContainerItemAnnotation, getContainerItemAnnotationConsideringFieldAndGetter, getContainerItemAnnotationConsideringFieldAndGetterIfSupported, getContainerItemAnnotationConsideringFieldAndGetterIfSupported, getDeclarationDetails, getDeclaredName, getDeclaredType, getDeclaringType, getDeclaringTypeMembers, getFakeContainerItemIndex, getMember, getName, getOverriddenName, getOverriddenType, getRawMember, getSchemaPropertyName, isFakeContainerItemScope, 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
-
FieldScope
protected FieldScope(com.fasterxml.classmate.members.ResolvedField field, MemberScope.DeclarationDetails declarationDetails, com.github.victools.jsonschema.generator.MemberScope.OverrideDetails overrideDetails, TypeContext context)Constructor.- Parameters:
field- targeted fielddeclarationDetails- 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
-
withOverriddenType
public FieldScope withOverriddenType(com.fasterxml.classmate.ResolvedType overriddenType)
Description copied from class:MemberScopeCreate another instance for this field or method and context, but overriding the declared field/method return type with the given one.- Specified by:
withOverriddenTypein 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:MemberScopeCreate another instance for this field or method and context, but overriding the declared field/method name with the given one.- Specified by:
withOverriddenNamein 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()
-
asFakeContainerItemScope
public FieldScope asFakeContainerItemScope()
Description copied from class:MemberScopeCreate another instance for this field or method and context, representing its field/method return type's container item type.- Overrides:
asFakeContainerItemScopein classMemberScope<com.fasterxml.classmate.members.ResolvedField,Field>- Returns:
- new instance with the container item type as override (or an identical copy if this is not a container type)
- See Also:
MemberScope.withOverriddenType(ResolvedType),TypeScope.getContainerItemType(),MemberScope.isFakeContainerItemScope()
-
doGetSchemaPropertyName
protected String doGetSchemaPropertyName()
Returns the name to be used to reference this field in its parent's "properties".- Specified by:
doGetSchemaPropertyNamein 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 thetransientkeyword.- 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()
-
getContainerItemAnnotation
public <A extends Annotation> A getContainerItemAnnotation(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
Description copied from class:MemberScopeReturn 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:
getContainerItemAnnotationin classMemberScope<com.fasterxml.classmate.members.ResolvedField,Field>- 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)
-
getAnnotationConsideringFieldAndGetter
public <A extends Annotation> A getAnnotationConsideringFieldAndGetter(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
Description copied from class:MemberScopeReturn 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:
getAnnotationConsideringFieldAndGetterin classMemberScope<com.fasterxml.classmate.members.ResolvedField,Field>- 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)
-
getContainerItemAnnotationConsideringFieldAndGetter
public <A extends Annotation> A getContainerItemAnnotationConsideringFieldAndGetter(Class<A> annotationClass, Predicate<Annotation> considerOtherAnnotation)
Description copied from class:MemberScopeReturn 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:
getContainerItemAnnotationConsideringFieldAndGetterin classMemberScope<com.fasterxml.classmate.members.ResolvedField,Field>- 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)
-
-