note: this doesn't do interfaces right now take a type and expand it out recursively to a flat list of parameterized types. There's no ambiguity here --- type in Java take a fixed number of parameters
(Type c)
| 32 | * note: this doesn't do interfaces right now |
| 33 | * <p> |
| 34 | * take a type and expand it out recursively to a flat list of parameterized types. There's no ambiguity here --- type in Java take a fixed number of parameters |
| 35 | */ |
| 36 | static public List<Class> linearize(Type c) { |
| 37 | List<Class> r = new ArrayList<>(); |
| 38 | if (c instanceof ParameterizedType) { |
| 39 | r.add((Class) ((ParameterizedType) c).getRawType()); |
| 40 | Type[] args = ((ParameterizedType) c).getActualTypeArguments(); |
| 41 | for (Type t : args) { |
| 42 | r.addAll(linearize(t)); |
| 43 | } |
| 44 | } else if (c instanceof Class) |
| 45 | r.add((Class) c); |
| 46 | else if (c instanceof WildcardType) |
| 47 | r.addAll(linearize(((WildcardType) c).getUpperBounds()[0])); |
| 48 | return r; |
| 49 | } |
| 50 |
no test coverage detected