/** * TODO: this was copied from * org.eclipse.core.internal.expressions.Expressions is there a better place * to reference this? * * @param element * The element to test; may be <code>null</code>. * @param type * The type against which we are testing;may be <code>null</code>. * @return <code>true</code> if the <code>element</code> is an instance * of <code>type</code>; <code>false</code> otherwise. */ private static final boolean isInstanceOf(final Object element, final String type) { // null isn't an instanceof of anything. if (element == null) { return false; } return isSubtype(element.getClass(), type); }
/** * TODO: this was copied from * org.eclipse.core.internal.expressions.Expressions is there a better place * to reference this? * * @param element * The element to test; may be <code>null</code>. * @param type * The type against which we are testing;may be <code>null</code>. * @return <code>true</code> if the <code>element</code> is an instance * of <code>type</code>; <code>false</code> otherwise. */ private static final boolean isInstanceOf(final Object element, final String type) { // null isn't an instanceof of anything. if (element == null) { return false; } return isSubtype(element.getClass(), type); }
/** * TODO: this was copied from * org.eclipse.core.internal.expressions.Expressions is there a better place * to reference this? * * @param element * The element to test; may be <code>null</code>. * @param type * The type against which we are testing;may be <code>null</code>. * @return <code>true</code> if the <code>element</code> is an instance * of <code>type</code>; <code>false</code> otherwise. */ private static final boolean isInstanceOf(final Object element, final String type) { // null isn't an instanceof of anything. if (element == null) { return false; } return isSubtype(element.getClass(), type); }
/** * TODO: this was copied from * org.eclipse.core.internal.expressions.Expressions is there a better place * to reference this? * * @param clazz * The class to match; may be <code>null</code>. * @param type * The type against which we are testing;may be <code>null</code>. * @return <code>true</code> if the <code>element</code> is an instance * of <code>type</code>; <code>false</code> otherwise. */ private static final boolean isSubtype(final Class<?> clazz, final String type) { if (clazz.getName().equals(type)) { return true; } final Class<?> superClass = clazz.getSuperclass(); if (superClass != null && isSubtype(superClass, type)) { return true; } final Class<?>[] interfaces = clazz.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { if (isSubtype(interfaces[i], type)) { return true; } } return false; }
/** * TODO: this was copied from * org.eclipse.core.internal.expressions.Expressions is there a better place * to reference this? * * @param clazz * The class to match; may be <code>null</code>. * @param type * The type against which we are testing;may be <code>null</code>. * @return <code>true</code> if the <code>element</code> is an instance * of <code>type</code>; <code>false</code> otherwise. */ private static final boolean isSubtype(final Class<?> clazz, final String type) { if (clazz.getName().equals(type)) { return true; } final Class<?> superClass = clazz.getSuperclass(); if (superClass != null && isSubtype(superClass, type)) { return true; } for (Class<?> classInterface : clazz.getInterfaces()) { if (isSubtype(classInterface, type)) { return true; } } return false; }
/** * TODO: this was copied from * org.eclipse.core.internal.expressions.Expressions is there a better place * to reference this? * * @param clazz * The class to match; may be <code>null</code>. * @param type * The type against which we are testing;may be <code>null</code>. * @return <code>true</code> if the <code>element</code> is an instance * of <code>type</code>; <code>false</code> otherwise. */ private static final boolean isSubtype(final Class<?> clazz, final String type) { if (clazz.getName().equals(type)) { return true; } final Class<?> superClass = clazz.getSuperclass(); if (superClass != null && isSubtype(superClass, type)) { return true; } final Class<?>[] interfaces = clazz.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { if (isSubtype(interfaces[i], type)) { return true; } } return false; }