Skip to content

Commit

Permalink
Minor refactoring wrt Enum resolver construction needed for #2787
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 6, 2023
1 parent 7161d21 commit d87575b
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1704,8 +1704,7 @@ public JsonDeserializer<?> createEnumDeserializer(DeserializationContext ctxt,

// Need to consider @JsonValue if one found
if (deser == null) {
deser = new EnumDeserializer(constructEnumResolver(enumClass,
config, beanDesc.findJsonValueAccessor()),
deser = new EnumDeserializer(constructEnumResolver(enumClass, config, beanDesc),
config.isEnabled(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS),
constructEnumNamingStrategyResolver(config, enumClass, beanDesc.getClassInfo())
);
Expand Down Expand Up @@ -1914,7 +1913,7 @@ private KeyDeserializer _createEnumKeyDeserializer(DeserializationContext ctxt,
return StdKeyDeserializers.constructDelegatingKeyDeserializer(config, type, valueDesForKey);
}
}
EnumResolver enumRes = constructEnumResolver(enumClass, config, beanDesc.findJsonValueAccessor());
EnumResolver enumRes = constructEnumResolver(enumClass, config, beanDesc);
EnumResolver byEnumNamingResolver = constructEnumNamingStrategyResolver(config, enumClass, beanDesc.getClassInfo());

// May have @JsonCreator for static factory method
Expand Down Expand Up @@ -2412,14 +2411,15 @@ protected JavaType resolveMemberAndTypeAnnotations(DeserializationContext ctxt,
}

protected EnumResolver constructEnumResolver(Class<?> enumClass,
DeserializationConfig config, AnnotatedMember jsonValueAccessor)
DeserializationConfig config, BeanDescription beanDesc)
{
if (jsonValueAccessor != null) {
AnnotatedMember jvAcc = beanDesc.findJsonValueAccessor();
if (jvAcc != null) {
if (config.canOverrideAccessModifiers()) {
ClassUtil.checkAndFixAccess(jsonValueAccessor.getMember(),
ClassUtil.checkAndFixAccess(jvAcc.getMember(),
config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS));
}
return EnumResolver.constructUsingMethod(config, enumClass, jsonValueAccessor);
return EnumResolver.constructUsingMethod(config, enumClass, jvAcc);
}
// 14-Mar-2016, tatu: We used to check `DeserializationFeature.READ_ENUMS_USING_TO_STRING`
// here, but that won't do: it must be dynamically changeable...
Expand Down

0 comments on commit d87575b

Please sign in to comment.