@Test public void testSubClass() { final Object obj = new MyAnnotatedClass() {}; Assert.assertNotSame(MyAnnotatedClass.class, obj.getClass()); final Class cls = ModelHelper.getAnnotatedResourceClass(obj.getClass()); Assert.assertSame(MyAnnotatedClass.class, cls); }
public static Class<?> getAnnotatedResourceClass(final Class<?> resourceClass) { Class<?> foundInterface = null; Class<?> cls = resourceClass; do { if (cls.isAnnotationPresent(Path.class)) { return cls; } if (foundInterface == null) { for (final Class<?> i : cls.getInterfaces()) { if (i.isAnnotationPresent(Path.class)) { foundInterface = i; break; } } } } while ((cls = cls.getSuperclass()) != null); if (foundInterface != null) { return foundInterface; } return resourceClass; }
ModelHelper { public static Class<?> getAnnotatedResourceClass(final Class<?> resourceClass) { Class<?> foundInterface = null; Class<?> cls = resourceClass; do { if (cls.isAnnotationPresent(Path.class)) { return cls; } if (foundInterface == null) { for (final Class<?> i : cls.getInterfaces()) { if (i.isAnnotationPresent(Path.class)) { foundInterface = i; break; } } } } while ((cls = cls.getSuperclass()) != null); if (foundInterface != null) { return foundInterface; } return resourceClass; } }
ModelHelper { public static Class<?> getAnnotatedResourceClass(final Class<?> resourceClass) { Class<?> foundInterface = null; Class<?> cls = resourceClass; do { if (cls.isAnnotationPresent(Path.class)) { return cls; } if (foundInterface == null) { for (final Class<?> i : cls.getInterfaces()) { if (i.isAnnotationPresent(Path.class)) { foundInterface = i; break; } } } } while ((cls = cls.getSuperclass()) != null); if (foundInterface != null) { return foundInterface; } return resourceClass; } private  ModelHelper(); }
ModelHelper { public static Class<?> getAnnotatedResourceClass(final Class<?> resourceClass) { Class<?> foundInterface = null; Class<?> cls = resourceClass; do { if (cls.isAnnotationPresent(Path.class)) { return cls; } if (foundInterface == null) { for (final Class<?> i : cls.getInterfaces()) { if (i.isAnnotationPresent(Path.class)) { foundInterface = i; break; } } } } while ((cls = cls.getSuperclass()) != null); if (foundInterface != null) { return foundInterface; } return resourceClass; } private  ModelHelper(); static Class<?> getAnnotatedResourceClass(final Class<?> resourceClass); }
ModelHelper { public static Class<?> getAnnotatedResourceClass(final Class<?> resourceClass) { Class<?> foundInterface = null; Class<?> cls = resourceClass; do { if (cls.isAnnotationPresent(Path.class)) { return cls; } if (foundInterface == null) { for (final Class<?> i : cls.getInterfaces()) { if (i.isAnnotationPresent(Path.class)) { foundInterface = i; break; } } } } while ((cls = cls.getSuperclass()) != null); if (foundInterface != null) { return foundInterface; } return resourceClass; } private  ModelHelper(); static Class<?> getAnnotatedResourceClass(final Class<?> resourceClass);  }