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 using == comparisons e.g:
type == String.class // works
but this doesn't seem to work for the Enum class:
type == Enum.class // doesn't work
... this makes sense as the instance would be of a specific enum but I would like to check whether the type is for any enum or not.
Could someone explain the obvious to me of how to tell whether the Type is an enum or not please
Why don't you use .equals method to compare this type of comparisons. == is mostly used for primitive types.
or maybe you will need compare your own classes.
Class.isEnum() will do it for you.
Refer to Oracle Doc