Total Complexity | 5 |
Total Lines | 21 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package com.hltech.pact.gen.domain.client.util; |
||
12 | public class TypeExtractor { |
||
13 | |||
14 | private TypeExtractor() {} |
||
15 | |||
16 | public static List<Class<?>> extractParameterTypesFromType(Type type) { |
||
17 | if (type == null) { |
||
18 | return new ArrayList<>(); |
||
19 | } |
||
20 | |||
21 | if (type instanceof ParameterizedType) { |
||
22 | ParameterizedType paramType = (ParameterizedType)type; |
||
23 | return Arrays.stream(paramType.getActualTypeArguments()) |
||
24 | .map(a -> (Class<?>)a) |
||
25 | .collect(Collectors.toList()); |
||
26 | } |
||
27 | |||
28 | if (((Class<?>)type).isArray()) { |
||
29 | return Lists.newArrayList(((Class<?>)type).getComponentType()); |
||
30 | } |
||
31 | |||
32 | return Lists.newArrayList(); |
||
33 | } |
||
35 |