osglworks/java-tool

`Generics.buildTypeParamImplLookup` - support nested type params

Closed this issue · 0 comments

Sample code:

public class Gh197 extends TestBase {

    public static class GrandParent<T> {
        T t;
    }

    public static class Req<V, ID> {
        ID id;
        V v;
    }

    public static class Parent<K, V, RQ extends Req<K, V>> extends GrandParent<RQ> {
    }

    public static class Me extends Parent<String, Integer, Req<String, Integer>> {}

    @Test
    public void test() {
        Map<String, Class> lookup = Generics.buildTypeParamImplLookup(Me.class);
        eq(String.class, lookup.get("K"));
        eq(Integer.class, lookup.get("V"));
        eq(Req.class, lookup.get("RQ"));
        eq(String.class, lookup.get("RQ.V"));
    }
}