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

前端 未结 1 1544
小鲜肉
小鲜肉 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<String> stringList = new ArrayList<String>() {};
    Class<?> stringType = TypeResolver.resolveRawArgument(List.class, stringList.getClass());
    assert stringType == String.class;
    
    0 讨论(0)
提交回复
热议问题