#984 extract method for annotation value check

This commit is contained in:
Simulant 2025-06-25 23:08:01 +02:00
parent 916fba5d39
commit 5063d314a5

View File

@ -1828,7 +1828,7 @@ public class JSONObject {
}
}
JSONPropertyName annotation = getAnnotation(method, JSONPropertyName.class);
if (annotation != null && annotation.value() != null && !annotation.value().isEmpty()) {
if (annotationValueNotEmpty(annotation)) {
return annotation.value();
}
String key;
@ -1854,6 +1854,15 @@ public class JSONObject {
return key;
}
/**
* checks if the annotation is not null and the {@link JSONPropertyName#value()} is not null and is not empty.
* @param annotation the annotation to check
* @return true if the annotation and the value is not null and not empty, false otherwise.
*/
private static boolean annotationValueNotEmpty(JSONPropertyName annotation) {
return annotation != null && annotation.value() != null && !annotation.value().isEmpty();
}
/**
* Checks if the method is valid for the {@link #populateMap(Object, Set, JSONParserConfiguration)} use case
* @param method the Method to check