|
3 | 3 | * * |
4 | 4 | * * * |
5 | 5 | * * * * |
6 | | - * * * * * Copyright 2019-2022 the original author or authors. |
| 6 | + * * * * * Copyright 2019-2023 the original author or authors. |
7 | 7 | * * * * * |
8 | 8 | * * * * * Licensed under the Apache License, Version 2.0 (the "License"); |
9 | 9 | * * * * * you may not use this file except in compliance with the License. |
@@ -124,31 +124,16 @@ public static MethodParameter[] customize(String[] pNames, MethodParameter[] par |
124 | 124 | MethodParameter p = parameters[i]; |
125 | 125 | Class<?> paramClass = AdditionalModelsConverter.getParameterObjectReplacement(p.getParameterType()); |
126 | 126 |
|
127 | | - if (!MethodParameterPojoExtractor.isSimpleType(paramClass) && (p.hasParameterAnnotation(ParameterObject.class) || AnnotatedElementUtils.isAnnotated(paramClass, ParameterObject.class))) { |
| 127 | + boolean hasFlatAnnotation = p.hasParameterAnnotation(ParameterObject.class) || AnnotatedElementUtils.isAnnotated(paramClass, ParameterObject.class); |
| 128 | + boolean hasNotFlatAnnotation = Arrays.stream(p.getParameterAnnotations()) |
| 129 | + .anyMatch(annotation -> Arrays.asList(RequestBody.class, RequestPart.class).contains(annotation.annotationType())); |
| 130 | + if (!MethodParameterPojoExtractor.isSimpleType(paramClass) |
| 131 | + && (hasFlatAnnotation || (defaultFlatParamObject && !hasNotFlatAnnotation && !AbstractRequestService.isRequestTypeToIgnore(paramClass)))) { |
128 | 132 | MethodParameterPojoExtractor.extractFrom(paramClass).forEach(methodParameter -> { |
129 | 133 | optionalDelegatingMethodParameterCustomizer.ifPresent(customizer -> customizer.customize(p, methodParameter)); |
130 | 134 | explodedParameters.add(methodParameter); |
131 | 135 | }); |
132 | 136 | } |
133 | | - else if (defaultFlatParamObject) { |
134 | | - boolean isSimpleType = MethodParameterPojoExtractor.isSimpleType(paramClass); |
135 | | - List<Annotation> annotations = Arrays.stream(p.getParameterAnnotations()) |
136 | | - .filter(annotation -> Arrays.asList(RequestBody.class, RequestPart.class).contains(annotation.annotationType())) |
137 | | - .toList(); |
138 | | - boolean hasAnnotation = !annotations.isEmpty(); |
139 | | - boolean shouldFlat = !isSimpleType && !hasAnnotation; |
140 | | - if (shouldFlat && !AbstractRequestService.isRequestTypeToIgnore(paramClass)) { |
141 | | - MethodParameterPojoExtractor.extractFrom(paramClass).forEach(methodParameter -> { |
142 | | - optionalDelegatingMethodParameterCustomizer |
143 | | - .ifPresent(customizer -> customizer.customize(p, methodParameter)); |
144 | | - explodedParameters.add(methodParameter); |
145 | | - }); |
146 | | - } |
147 | | - else { |
148 | | - String name = pNames != null ? pNames[i] : p.getParameterName(); |
149 | | - explodedParameters.add(new DelegatingMethodParameter(p, name, null, false, false)); |
150 | | - } |
151 | | - } |
152 | 137 | else { |
153 | 138 | String name = pNames != null ? pNames[i] : p.getParameterName(); |
154 | 139 | explodedParameters.add(new DelegatingMethodParameter(p, name, null, false, false)); |
|
0 commit comments