Aurasphere Aurasphere - 1 year ago 81
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.

Answer Source


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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download