|
6 | 6 | import com.fasterxml.jackson.annotation.JacksonInject;
|
7 | 7 | import com.fasterxml.jackson.annotation.JsonCreator;
|
8 | 8 |
|
| 9 | +import com.fasterxml.jackson.annotation.JsonFormat; |
9 | 10 | import com.fasterxml.jackson.databind.*;
|
10 | 11 | import com.fasterxml.jackson.databind.cfg.HandlerInstantiator;
|
11 | 12 | import com.fasterxml.jackson.databind.cfg.MapperConfig;
|
@@ -1123,6 +1124,10 @@ protected void _renameProperties(Map<String, POJOPropertyBuilder> props)
|
1123 | 1124 | protected void _renameUsing(Map<String, POJOPropertyBuilder> propMap,
|
1124 | 1125 | PropertyNamingStrategy naming)
|
1125 | 1126 | {
|
| 1127 | + // [databind#4409]: Need to skip renaming for Enums, unless Enums are handled as OBJECT format |
| 1128 | + if (_type.isEnumType() && (_findFormatShape() != JsonFormat.Shape.OBJECT)) { |
| 1129 | + return; |
| 1130 | + } |
1126 | 1131 | POJOPropertyBuilder[] props = propMap.values().toArray(new POJOPropertyBuilder[propMap.size()]);
|
1127 | 1132 | propMap.clear();
|
1128 | 1133 | for (POJOPropertyBuilder prop : props) {
|
@@ -1171,6 +1176,29 @@ protected void _renameUsing(Map<String, POJOPropertyBuilder> propMap,
|
1171 | 1176 | }
|
1172 | 1177 | }
|
1173 | 1178 |
|
| 1179 | + /** |
| 1180 | + * Helper method called to check if given property should be renamed using {@link PropertyNamingStrategies}. |
| 1181 | + *<p> |
| 1182 | + * NOTE: copied+simplified version of {@code BasicBeanDescription.findExpectedFormat()}. |
| 1183 | + * |
| 1184 | + * @since 2.16.2 |
| 1185 | + */ |
| 1186 | + private JsonFormat.Shape _findFormatShape() |
| 1187 | + { |
| 1188 | + JsonFormat.Shape shape = null; |
| 1189 | + JsonFormat.Value format = _annotationIntrospector.findFormat(_classDef); |
| 1190 | + if (format != null) { |
| 1191 | + shape = format.getShape(); |
| 1192 | + } |
| 1193 | + JsonFormat.Value defFormat = _config.getDefaultPropertyFormat(_classDef.getRawType()); |
| 1194 | + if (defFormat != null) { |
| 1195 | + if (shape == null) { |
| 1196 | + shape = defFormat.getShape(); |
| 1197 | + } |
| 1198 | + } |
| 1199 | + return shape; |
| 1200 | + } |
| 1201 | + |
1174 | 1202 | protected void _renameWithWrappers(Map<String, POJOPropertyBuilder> props)
|
1175 | 1203 | {
|
1176 | 1204 | // 11-Sep-2012, tatu: To support 'MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME',
|
|
0 commit comments