how would i go about iterating resolved generics recursively?
specifically my intent is to provide hierarchical type information, leveraging Generics Resolver to do the hard work for me
(cus i tried and failed many times to manually resolve generics, fix one thing and something breaks somewhere else, fix that and something else breaks, qwq)
for example
// List<List<String[]>[]> a;
field: a ( with return type: List<List<String[]>[]> )
return type:
{
type: List
generic parameters: 1
{
{
type: List
rank: 1
generic parameters: 1
{
{
type: String
rank: 1
}
}
}
}
}
class Foo <T> {
List<List<String[]>[]> a(boolean r, T z);
}
try {
// get the field of new C__<Serializable>().foo.get(0)[0].values().iterator().next().second
TypeInfo foo = TypeInfo.getFieldRecursive(C__.class, "foo");
for (TypeInfo foo2 : TypeInfo.getMethodsRecursive(foo.getReturnType(), "get")) {
for (TypeInfo foo3 : TypeInfo.getMethodsRecursive(foo2.getReturnType(), "values")) {
for (TypeInfo foo4 : TypeInfo.getMethodsRecursive(foo3.getReturnType(), "iterator")) {
for (TypeInfo foo5 : TypeInfo.getMethodsRecursive(foo4.getReturnType(), "next")) {
TypeInfo foo6 = TypeInfo.getFieldRecursive(foo5.getReturnType(), "second");
// get the field of new C__<StringBuilder>().foo.get(0)[0].values().iterator().next().first
TypeInfo foo7 = TypeInfo.getFieldRecursive(foo6.getReturnType(), "foo");
foo7.printDetailed();
for (TypeInfo foo8 : TypeInfo.getMethodsRecursive(foo7.getReturnType(), "get")) {
for (TypeInfo foo9 : TypeInfo.getMethodsRecursive(foo8.getReturnType(), "values")) {
for (TypeInfo foo10 : TypeInfo.getMethodsRecursive(foo9.getReturnType(), "iterator")) {
for (TypeInfo foo11 : TypeInfo.getMethodsRecursive(foo10.getReturnType(), "next")) {
TypeInfo foo12 = TypeInfo.getFieldRecursive(foo11.getReturnType(), "first");
foo12.printDetailed();
}
}
}
}
}
}
}
}
} catch (NoSuchMethodException | NoSuchFieldException e) {
throw new RuntimeException(e);
}
and it outputs
TypeInfo {
field: private smallville7123.Main.C__#foo ( with return type: public abstract interface java.util.List<public java.util.HashMap<public final java.lang.StringBuilder[][], public smallville7123.reflectui.utils.Pair<public final java.lang.StringBuilder[], internal smallville7123.Main.C__<public final java.lang.StringBuilder>>>[]> )
field type:
TypeInfo {
type: public abstract interface java.util.List<public java.util.HashMap<public final java.lang.StringBuilder[][], public smallville7123.reflectui.utils.Pair<public final java.lang.StringBuilder[], internal smallville7123.Main.C__<public final java.lang.StringBuilder>>>[]>
isGeneric: true
genericParameters: 1
TypeInfo {
type: public java.util.HashMap<public final java.lang.StringBuilder[][], public smallville7123.reflectui.utils.Pair<public final java.lang.StringBuilder[], internal smallville7123.Main.C__<public final java.lang.StringBuilder>>>[]
isGeneric: true
typeRank: 1
genericParameters: 2
TypeInfo {
type: public final java.lang.StringBuilder[][]
typeRank: 2
}
TypeInfo {
type: public smallville7123.reflectui.utils.Pair<public final java.lang.StringBuilder[], internal smallville7123.Main.C__<public final java.lang.StringBuilder>>
isGeneric: true
genericParameters: 2
TypeInfo {
type: public final java.lang.StringBuilder[]
typeRank: 1
}
TypeInfo {
type: internal smallville7123.Main.C__<public final java.lang.StringBuilder>
isGeneric: true
genericParameters: 1
TypeInfo {
type: public final java.lang.StringBuilder
}
}
}
}
}
}
TypeInfo {
field: public smallville7123.reflectui.utils.Pair#first ( with return type: public final java.lang.StringBuilder )
field type:
TypeInfo {
type: public final java.lang.StringBuilder
}
}
and
class GenericFields {
public Pair<Pair<Pair<Integer, Boolean>[][], Pair<Integer, Boolean>[][]>[][], Pair<Pair<Integer, Boolean>[][], Pair<Integer, Boolean>[][]>[][]>[][] integerBooleanPairMulti;
}
how would i go about iterating resolved generics recursively?
specifically my intent is to provide hierarchical type information, leveraging Generics Resolver to do the hard work for me
(cus i tried and failed many times to manually resolve generics, fix one thing and something breaks somewhere else, fix that and something else breaks, qwq)
for example
specifically, with my old library i could do:
give it
and it outputs
and
and i am wondering how i could replicate most of this functionality with
Generics Resolver