TypeHelper { @Deprecated public static boolean isA(final TypeNode n, final String clazzName) { Objects.requireNonNull(n); return clazzName != null && TypeTestUtil.isA(clazzName, n); } private  TypeHelper(); @Deprecated static boolean isA(final TypeNode n, final String clazzName); @Deprecated static boolean isExactlyA(final TypeNode n, final String clazzName); @Deprecated static boolean isA(TypeNode n, Class<?> clazz); @Deprecated static boolean isEither(TypeNode n, Class<?> class1, Class<?> class2); @Deprecated static boolean isExactlyAny(TypedNameDeclaration vnd, Class<?>... clazzes); @Deprecated static boolean isExactlyNone(TypedNameDeclaration vnd, Class<?>... clazzes); @Deprecated static boolean isA(TypedNameDeclaration vnd, Class<?> clazz); @Deprecated static boolean isEither(TypedNameDeclaration vnd, Class<?> class1, Class<?> class2); @Deprecated static boolean isNeither(TypedNameDeclaration vnd, Class<?> class1, Class<?> class2); @Deprecated static boolean subclasses(TypeNode n, Class<?> clazz); static boolean isA(TypedNameDeclaration vnd, String className);  }
@Test public void testIsAFallback() { ASTClassOrInterfaceDeclaration klass = java.parse("package org; import java.io.Serializable; " + "class FooBar implements Serializable {}") .getFirstDescendantOfType(ASTClassOrInterfaceDeclaration.class); Assert.assertNull(klass.getType()); Assert.assertTrue(TypeHelper.isA(klass, "org.FooBar")); Assert.assertTrue(TypeHelper.isA(klass, "java.io.Serializable")); Assert.assertTrue(TypeHelper.isA(klass, Serializable.class)); }
@Test public void testIsAFallbackEnum() { ASTEnumDeclaration klass = java.parse("package org; " + "enum FooBar implements Iterable {}") .getFirstDescendantOfType(ASTEnumDeclaration.class); Assert.assertNull(klass.getType()); Assert.assertTrue(TypeHelper.isA(klass, "org.FooBar")); assertIsA(klass, Iterable.class); assertIsA(klass, Enum.class); assertIsA(klass, Serializable.class); assertIsA(klass, Object.class); }
@Test public void testIsAFallbackAnnotation() { ASTAnnotationTypeDeclaration klass = java.parse("package org; import foo.Stuff;" + "public @interface FooBar {}") .getFirstDescendantOfType(ASTAnnotationTypeDeclaration.class); Assert.assertNull(klass.getType()); Assert.assertTrue(TypeHelper.isA(klass, "org.FooBar")); assertIsA(klass, Annotation.class); assertIsA(klass, Object.class); }
@Test public void testIsAFallbackAnnotationSimpleNameImport() { ASTName annotation = java.parse("package org; import foo.Stuff; @Stuff public class FooBar {}") .getFirstDescendantOfType(ASTMarkerAnnotation.class).getFirstChildOfType(ASTName.class); Assert.assertNull(annotation.getType()); Assert.assertTrue(TypeHelper.isA(annotation, "foo.Stuff")); Assert.assertFalse(TypeHelper.isA(annotation, "other.Stuff")); Assert.assertTrue(TypeHelper.isA(annotation, "Stuff")); }