Simplified to not use Optional
(2022)
@@ -30,6 +30,7 @@ import java.util.function.Predicate;
import static java.util.Optional.*;
import static org.springframework.core.annotation.AnnotationUtils.*;
+import static springfox.documentation.builders.BuilderDefaults.*;
@Component
@Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER)
@@ -39,9 +40,11 @@ public class ApiModelTypeNameProvider extends DefaultTypeNameProvider {
ApiModel annotation = findAnnotation(type, ApiModel.class);
String defaultTypeName = super.nameFor(type);
if (annotation != null) {
- return ofNullable(annotation.value())
- .filter(((Predicate<String>) String::isEmpty).negate())
- .orElse(defaultTypeName);
+ String value = nullToEmpty(annotation.value());
+ if (value.length() == 0) {
+ return defaultTypeName;
+ }
+ return value;
}
return defaultTypeName;
}
