Aurasphere Aurasphere - 1 month ago 8
Java Question

Check javax.lang.model.type.TypeMirror is a primitive type

Is there any way I can check that a

is a primitive type? I've tried
instanceof PrimitiveType
but this always yields true since
extends TypeMirror.

Thank you for the help.



To implement operations based on the class of an TypeMirror object, either use a visitor or use the result of the getKind() method. Using instanceof is not necessarily a reliable idiom for determining the effective class of an object in this modeling hierarchy since an implementation may choose to have a single object implement multiple TypeMirror subinterfaces.

Try calling getKind() rather than instanceOf.