MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / linearize

Method linearize

src/main/java/field/utility/Conversions.java:34–47  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 3

functionMethod · 0.95
typeMethod · 0.95

Calls 2

addMethod · 0.45
addAllMethod · 0.45

Tested by

no test coverage detected