@Test public void testGetInterfaces() { Assertions.assertArrayEquals(new Object[]{Serializable.class}, ReflectionUtil.getInterfaces(Serializable.class).toArray()); Assertions.assertArrayEquals(new Object[]{ Serializable.class, Comparable.class, CharSequence.class}, ReflectionUtil.getInterfaces(String.class).toArray()); }
public static Set<Class<?>> getInterfaces(Class<?> clazz) { if (clazz.isInterface()) { return Collections.singleton(clazz); } Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>(); while (clazz != null) { Class<?>[] ifcs = clazz.getInterfaces(); for (Class<?> ifc : ifcs) { interfaces.addAll(getInterfaces(ifc)); } clazz = clazz.getSuperclass(); } return interfaces; }
ReflectionUtil { public static Set<Class<?>> getInterfaces(Class<?> clazz) { if (clazz.isInterface()) { return Collections.singleton(clazz); } Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>(); while (clazz != null) { Class<?>[] ifcs = clazz.getInterfaces(); for (Class<?> ifc : ifcs) { interfaces.addAll(getInterfaces(ifc)); } clazz = clazz.getSuperclass(); } return interfaces; } }
ReflectionUtil { public static Set<Class<?>> getInterfaces(Class<?> clazz) { if (clazz.isInterface()) { return Collections.singleton(clazz); } Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>(); while (clazz != null) { Class<?>[] ifcs = clazz.getInterfaces(); for (Class<?> ifc : ifcs) { interfaces.addAll(getInterfaces(ifc)); } clazz = clazz.getSuperclass(); } return interfaces; }  }
ReflectionUtil { public static Set<Class<?>> getInterfaces(Class<?> clazz) { if (clazz.isInterface()) { return Collections.singleton(clazz); } Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>(); while (clazz != null) { Class<?>[] ifcs = clazz.getInterfaces(); for (Class<?> ifc : ifcs) { interfaces.addAll(getInterfaces(ifc)); } clazz = clazz.getSuperclass(); } return interfaces; }  static Class<?> getClassByName(String className); static Object getFieldValue(Object target, String fieldName); static Object invokeMethod(Object target, String methodName); static Object invokeMethod(Object target, String methodName, Class<?>[] parameterTypes, Object[] args); static Object invokeStaticMethod(Class<?> targetClass, String methodName, Class<?>[] parameterTypes,
                                            Object[] parameterValues); static Method getMethod(Class<?> classType, String methodName, Class<?>[] parameterTypes); static Set<Class<?>> getInterfaces(Class<?> clazz); }
ReflectionUtil { public static Set<Class<?>> getInterfaces(Class<?> clazz) { if (clazz.isInterface()) { return Collections.singleton(clazz); } Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>(); while (clazz != null) { Class<?>[] ifcs = clazz.getInterfaces(); for (Class<?> ifc : ifcs) { interfaces.addAll(getInterfaces(ifc)); } clazz = clazz.getSuperclass(); } return interfaces; }  static Class<?> getClassByName(String className); static Object getFieldValue(Object target, String fieldName); static Object invokeMethod(Object target, String methodName); static Object invokeMethod(Object target, String methodName, Class<?>[] parameterTypes, Object[] args); static Object invokeStaticMethod(Class<?> targetClass, String methodName, Class<?>[] parameterTypes,
                                            Object[] parameterValues); static Method getMethod(Class<?> classType, String methodName, Class<?>[] parameterTypes); static Set<Class<?>> getInterfaces(Class<?> clazz); static final int MAX_NEST_DEPTH; }