How to check if java.lang.reflect.Type is an Enum

后端 未结 4 1106
醉话见心
醉话见心 2020-12-30 23:16

I want to check whether a java.lang.reflect.Type instance represents an Emum object or not.

I can check whether it\'s an instance of a specific class us

4条回答
  •  Happy的楠姐
    2020-12-31 00:01

    Why don't you use .equals method to compare this type of comparisons. == is mostly used for primitive types.

    type.equals(Enum.class)
    

    or maybe you will need compare your own classes.

    type.equals(MyClass.class)
    

提交回复
热议问题