@Test public void testExtendsMany() { Class<Service> service = InterfaceUtils.getInterface(new ExtendsMany()); assertEquals(ExtendsSimple.class, service); }
@SuppressWarnings("unchecked") public static Class<Service> getInterface(final Service service) { Class<Service> clazz = null; Class<?> classExamining = service.getClass(); while (classExamining != null) { for (Class<?> intfClass : classExamining.getInterfaces()) { if (Service.class.isAssignableFrom(intfClass)) { clazz = (Class<Service>)intfClass; break; } } classExamining = classExamining.getSuperclass(); } return clazz; }
InterfaceUtils { @SuppressWarnings("unchecked") public static Class<Service> getInterface(final Service service) { Class<Service> clazz = null; Class<?> classExamining = service.getClass(); while (classExamining != null) { for (Class<?> intfClass : classExamining.getInterfaces()) { if (Service.class.isAssignableFrom(intfClass)) { clazz = (Class<Service>)intfClass; break; } } classExamining = classExamining.getSuperclass(); } return clazz; } }
InterfaceUtils { @SuppressWarnings("unchecked") public static Class<Service> getInterface(final Service service) { Class<Service> clazz = null; Class<?> classExamining = service.getClass(); while (classExamining != null) { for (Class<?> intfClass : classExamining.getInterfaces()) { if (Service.class.isAssignableFrom(intfClass)) { clazz = (Class<Service>)intfClass; break; } } classExamining = classExamining.getSuperclass(); } return clazz; }  }
InterfaceUtils { @SuppressWarnings("unchecked") public static Class<Service> getInterface(final Service service) { Class<Service> clazz = null; Class<?> classExamining = service.getClass(); while (classExamining != null) { for (Class<?> intfClass : classExamining.getInterfaces()) { if (Service.class.isAssignableFrom(intfClass)) { clazz = (Class<Service>)intfClass; break; } } classExamining = classExamining.getSuperclass(); } return clazz; }  @SuppressWarnings("unchecked") static Class<Service> getInterface(final Service service); }
InterfaceUtils { @SuppressWarnings("unchecked") public static Class<Service> getInterface(final Service service) { Class<Service> clazz = null; Class<?> classExamining = service.getClass(); while (classExamining != null) { for (Class<?> intfClass : classExamining.getInterfaces()) { if (Service.class.isAssignableFrom(intfClass)) { clazz = (Class<Service>)intfClass; break; } } classExamining = classExamining.getSuperclass(); } return clazz; }  @SuppressWarnings("unchecked") static Class<Service> getInterface(final Service service);  }