isA<T extends JObject?> method
Whether this object is of the given type
ignoring the type parameters.
Warning
Because of Java generic type erasure, this method cannot distinguish
between two classes Foo<A>
and Foo<B>
as they are both of type
Foo
. Therefore, object.isA(Foo.type(A.type))
will return a
false-positive true
for objects of type Foo<B>
as well.
For example:
if (object.isA(JLong.type)) {
final i = object.as(JLong.type).longValue;
...
}
Implementation
bool isA<T extends JObject?>(JObjType<T> type) {
final targetJClass = type.jClass;
final canBeCasted = isInstanceOf(targetJClass);
targetJClass.release();
return canBeCasted;
}