How to verify the (generic (generic argument))?

前端 未结 1 1546
小鲜肉
小鲜肉 2021-01-15 09:32

Background (that we don\'t really need to worry about)

This is a question derived from Build A Generic Tree With Inheritance . I open this one as a separate questi

1条回答
  •  花落未央
    2021-01-15 10:04

    Check out TypeTools for this. Example:

    List stringList = new ArrayList() {};
    Class stringType = TypeResolver.resolveRawArgument(List.class, stringList.getClass());
    assert stringType == String.class;
    

    0 讨论(0)
提交回复
热议问题