Skip to content

Commit

Permalink
Merge branch '2.16'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jul 12, 2023
2 parents e14f857 + b4c073f commit 847ff8a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -869,47 +869,13 @@ public Boolean findAsValueAnnotation(MapperConfig<?> config, Annotated a) {
}
*/

@Override
public String[] findEnumValues(MapperConfig<?> config,
Class<?> enumType, Enum<?>[] enumValues, String[] names) {
HashMap<String,String> expl = null;
for (Field f : enumType.getDeclaredFields()) {
if (!f.isEnumConstant()) {
continue;
}
XmlEnumValue enumValue = f.getAnnotation(XmlEnumValue.class);
if (enumValue == null) {
continue;
}
String n = enumValue.value();
if (n.isEmpty()) {
continue;
}
if (expl == null) {
expl = new HashMap<String,String>();
}
expl.put(f.getName(), n);
}
// and then stitch them together if and as necessary
if (expl != null) {
for (int i = 0, end = enumValues.length; i < end; ++i) {
String defName = enumValues[i].name();
String explValue = expl.get(defName);
if (explValue != null) {
names[i] = explValue;
}
}
}
return names;
}

/**
* @see JacksonAnnotationIntrospector#findEnumValues(MapperConfig, AnnotatedClass, Enum[], String[])
* @since 2.16
*/
@Override
public String[] findEnumValues(MapperConfig<?> config, AnnotatedClass annotatedClass,
Enum<?>[] enumValues, String[] names)
Enum<?>[] enumValues, String[] names)
{
Map<String, String> enumToPropertyMap = new LinkedHashMap<String, String>();
for (AnnotatedField field : annotatedClass.fields()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,47 +869,13 @@ public Boolean findAsValueAnnotation(MapperConfig<?> config, Annotated a) {
}
*/

@Override
public String[] findEnumValues(MapperConfig<?> config,
Class<?> enumType, Enum<?>[] enumValues, String[] names) {
HashMap<String,String> expl = null;
for (Field f : enumType.getDeclaredFields()) {
if (!f.isEnumConstant()) {
continue;
}
XmlEnumValue enumValue = f.getAnnotation(XmlEnumValue.class);
if (enumValue == null) {
continue;
}
String n = enumValue.value();
if (n.isEmpty()) {
continue;
}
if (expl == null) {
expl = new HashMap<String,String>();
}
expl.put(f.getName(), n);
}
// and then stitch them together if and as necessary
if (expl != null) {
for (int i = 0, end = enumValues.length; i < end; ++i) {
String defName = enumValues[i].name();
String explValue = expl.get(defName);
if (explValue != null) {
names[i] = explValue;
}
}
}
return names;
}

/**
* @see JacksonAnnotationIntrospector#findEnumValues(MapperConfig, AnnotatedClass, Enum[], String[])
* @since 2.16
*/
@Override
public String[] findEnumValues(MapperConfig<?> config, AnnotatedClass annotatedClass,
Enum<?>[] enumValues, String[] names)
Enum<?>[] enumValues, String[] names)
{
Map<String, String> enumToPropertyMap = new LinkedHashMap<String, String>();
for (AnnotatedField field : annotatedClass.fields()) {
Expand Down

0 comments on commit 847ff8a

Please sign in to comment.