Skip to content

Commit

Permalink
Minor annotation introspector refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jul 6, 2024
1 parent 000f489 commit 475ebbf
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ public JavaType refineDeserializationType(final MapperConfig<?> config,

/*
/**********************************************************
/* Deserialization: class annotations
/* Deserialization: value instantiation, Creators
/**********************************************************
*/

Expand Down Expand Up @@ -1365,76 +1365,6 @@ public JsonPOJOBuilder.Value findPOJOBuilderConfig(AnnotatedClass ac) {
return null;
}

/*
/**********************************************************
/* Deserialization: property annotations
/**********************************************************
*/

/**
* Method for checking whether given property accessors (method,
* field) has an annotation that suggests property name to use
* for deserialization (reading JSON into POJOs).
* Should return null if no annotation
* is found; otherwise a non-null name (possibly
* {@link PropertyName#USE_DEFAULT}, which means "use default heuristics").
*
* @param ann Annotated entity to check
*
* @return Name to use if found; {@code null} if not.
*
* @since 2.1
*/
public PropertyName findNameForDeserialization(Annotated ann) {
return null;
}

/**
* Method for checking whether given method has an annotation
* that suggests that the method is to serve as "any setter";
* method to be used for setting values of any properties for
* which no dedicated setter method is found.
*
* @param ann Annotated entity to check
*
* @return {@code Boolean.TRUE} or {@code Boolean.FALSE} if explicit
* "any setter" marker found; {@code null} otherwise.
*
* @since 2.9
*/
public Boolean hasAnySetter(Annotated ann) {
return null;
}

/**
* Method for finding possible settings for property, given annotations
* on an accessor.
*
* @param ann Annotated entity to check
*
* @return Setter info value found, if any;
* {@code JsonSetter.Value.empty()} if none (should not return {@code null})
*
* @since 2.9
*/
public JsonSetter.Value findSetterInfo(Annotated ann) {
return JsonSetter.Value.empty();
}

/**
* Method for finding merge settings for property, if any.
*
* @param ann Annotated entity to check
*
* @return {@code Boolean.TRUE} or {@code Boolean.FALSE} if explicit
* merge enable/disable found; {@code null} otherwise.
*
* @since 2.9
*/
public Boolean findMergeInfo(Annotated ann) {
return null;
}

/**
* Method called to check whether potential Creator (constructor or static factory
* method) has explicit annotation to indicate it as actual Creator; and if so,
Expand Down Expand Up @@ -1504,6 +1434,76 @@ public JsonCreator.Mode findCreatorBinding(Annotated ann) {
return null;
}

/*
/**********************************************************
/* Deserialization: other property annotations
/**********************************************************
*/

/**
* Method for checking whether given property accessors (method,
* field) has an annotation that suggests property name to use
* for deserialization (reading JSON into POJOs).
* Should return null if no annotation
* is found; otherwise a non-null name (possibly
* {@link PropertyName#USE_DEFAULT}, which means "use default heuristics").
*
* @param ann Annotated entity to check
*
* @return Name to use if found; {@code null} if not.
*
* @since 2.1
*/
public PropertyName findNameForDeserialization(Annotated ann) {
return null;
}

/**
* Method for checking whether given method has an annotation
* that suggests that the method is to serve as "any setter";
* method to be used for setting values of any properties for
* which no dedicated setter method is found.
*
* @param ann Annotated entity to check
*
* @return {@code Boolean.TRUE} or {@code Boolean.FALSE} if explicit
* "any setter" marker found; {@code null} otherwise.
*
* @since 2.9
*/
public Boolean hasAnySetter(Annotated ann) {
return null;
}

/**
* Method for finding possible settings for property, given annotations
* on an accessor.
*
* @param ann Annotated entity to check
*
* @return Setter info value found, if any;
* {@code JsonSetter.Value.empty()} if none (should not return {@code null})
*
* @since 2.9
*/
public JsonSetter.Value findSetterInfo(Annotated ann) {
return JsonSetter.Value.empty();
}

/**
* Method for finding merge settings for property, if any.
*
* @param ann Annotated entity to check
*
* @return {@code Boolean.TRUE} or {@code Boolean.FALSE} if explicit
* merge enable/disable found; {@code null} otherwise.
*
* @since 2.9
*/
public Boolean findMergeInfo(Annotated ann) {
return null;
}

/**
* @param am Annotated method to check
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,11 @@ public JavaType refineDeserializationType(MapperConfig<?> config,
return _primary.refineDeserializationType(config, a, t);
}

// // // Deserialization: class annotations
/*
/**********************************************************************
/* Deserialization: value instantiation, Creators
/**********************************************************************
*/

@Override
public Object findValueInstantiator(AnnotatedClass ac) {
Expand All @@ -709,7 +713,33 @@ public JsonPOJOBuilder.Value findPOJOBuilderConfig(AnnotatedClass ac) {
return (result == null) ? _secondary.findPOJOBuilderConfig(ac) : result;
}

// // // Deserialization: method annotations
@Override
@Deprecated // since 2.9
public boolean hasCreatorAnnotation(Annotated a) {
return _primary.hasCreatorAnnotation(a) || _secondary.hasCreatorAnnotation(a);
}

@Override
@Deprecated // since 2.9
public JsonCreator.Mode findCreatorBinding(Annotated a) {
JsonCreator.Mode mode = _primary.findCreatorBinding(a);
if (mode != null) {
return mode;
}
return _secondary.findCreatorBinding(a);
}

@Override
public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated a) {
JsonCreator.Mode mode = _primary.findCreatorAnnotation(config, a);
return (mode == null) ? _secondary.findCreatorAnnotation(config, a) : mode;
}

/*
/**********************************************************************
/* Deserialization: other method annotations
/**********************************************************************
*/

@Override
public PropertyName findNameForDeserialization(Annotated a)
Expand Down Expand Up @@ -745,27 +775,6 @@ public Boolean findMergeInfo(Annotated a) {
return b;
}

@Override
@Deprecated // since 2.9
public boolean hasCreatorAnnotation(Annotated a) {
return _primary.hasCreatorAnnotation(a) || _secondary.hasCreatorAnnotation(a);
}

@Override
@Deprecated // since 2.9
public JsonCreator.Mode findCreatorBinding(Annotated a) {
JsonCreator.Mode mode = _primary.findCreatorBinding(a);
if (mode != null) {
return mode;
}
return _secondary.findCreatorBinding(a);
}

@Override
public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated a) {
JsonCreator.Mode mode = _primary.findCreatorAnnotation(config, a);
return (mode == null) ? _secondary.findCreatorAnnotation(config, a) : mode;
}

@Override
@Deprecated // since 2.9
Expand Down

0 comments on commit 475ebbf

Please sign in to comment.