From 84b45e9bb24229ff58d08a2180f640920da49dcb Mon Sep 17 00:00:00 2001 From: "Badr.NassLahsen" Date: Thu, 9 Mar 2023 15:01:17 +0100 Subject: [PATCH] code review --- .../api/AbstractOpenApiResource.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java b/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java index a1dcb54f1..276380afa 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java @@ -836,8 +836,9 @@ protected Set getDefaultAllowedHttpMethods() { * @return the operation */ protected Operation customizeOperation(Operation operation, HandlerMethod handlerMethod) { - if (springDocCustomizers.getOperationCustomizers().isPresent()) { - List operationCustomizerList = springDocCustomizers.getOperationCustomizers().get(); + Optional> optionalOperationCustomizers = springDocCustomizers.getOperationCustomizers(); + if (optionalOperationCustomizers.isPresent()) { + List operationCustomizerList = optionalOperationCustomizers.get(); for (OperationCustomizer operationCustomizer : operationCustomizerList) operation = operationCustomizer.customize(operation, handlerMethod); } @@ -846,13 +847,15 @@ protected Operation customizeOperation(Operation operation, HandlerMethod handle /** * Customise router operation - * @param routerOperation - * @param handlerMethod + * + * @param routerOperation the router operation + * @param handlerMethod the handler method * @return the router operation */ protected RouterOperation customizeRouterOperation(RouterOperation routerOperation, HandlerMethod handlerMethod) { - if (springDocCustomizers.getRouterOperationCustomizers().isPresent()) { - List routerOperationCustomizerList = springDocCustomizers.getRouterOperationCustomizers().get(); + Optional> optionalRouterOperationCustomizers = springDocCustomizers.getRouterOperationCustomizers(); + if (optionalRouterOperationCustomizers.isPresent()) { + List routerOperationCustomizerList = optionalRouterOperationCustomizers.get(); for (RouterOperationCustomizer routerOperationCustomizer : routerOperationCustomizerList) { routerOperation = routerOperationCustomizer.customize(routerOperation, handlerMethod); } @@ -1356,8 +1359,9 @@ enum ConditionType { * @return the router operation */ private RouterOperation customizeDataRestRouterOperation(RouterOperation routerOperation) { - if (springDocCustomizers.getDataRestRouterOperationCustomizers().isPresent()) { - List dataRestRouterOperationCustomizerList = springDocCustomizers.getDataRestRouterOperationCustomizers().get(); + Optional> optionalDataRestRouterOperationCustomizers = springDocCustomizers.getDataRestRouterOperationCustomizers(); + if (optionalDataRestRouterOperationCustomizers.isPresent()) { + List dataRestRouterOperationCustomizerList = optionalDataRestRouterOperationCustomizers.get(); for (DataRestRouterOperationCustomizer dataRestRouterOperationCustomizer : dataRestRouterOperationCustomizerList) { routerOperation = dataRestRouterOperationCustomizer.customize(routerOperation); }