Total Complexity | 5 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package com.hltech.pact.gen.domain.client.util; |
||
13 | public final class PathParametersExtractor { |
||
14 | |||
15 | private PathParametersExtractor() {} |
||
16 | |||
17 | public static List<Param> extractAll(Method feignClientMethod) { |
||
18 | return Arrays.stream(feignClientMethod.getParameters()) |
||
19 | .filter(param -> param.getAnnotation(PathVariable.class) != null) |
||
20 | .filter(param -> param.getType() != Map.class) |
||
21 | .map(PathParametersExtractor::extract) |
||
22 | .collect(Collectors.toList()); |
||
23 | } |
||
24 | |||
25 | private static Param extract(Parameter param) { |
||
26 | PathVariable annotation = param.getAnnotation(PathVariable.class); |
||
27 | |||
28 | List<Class<?>> paramTypes = TypeExtractor.extractParameterTypesFromType(param.getParameterizedType()); |
||
29 | |||
30 | return Param.builder() |
||
31 | .name(annotation.name().isEmpty() ? annotation.value() : annotation.name()) |
||
32 | .type(param.getType()) |
||
33 | .genericArgumentType(paramTypes.isEmpty() ? null : paramTypes.get(0)) |
||
34 | .build(); |
||
35 | } |
||
37 |