List of usage examples for java.lang Class getInterfaces
public Class<?>[] getInterfaces()
From source file:Main.java
private static boolean isAnnotationPresentOnInterfaces(Class<?> clazz, Class<? extends Annotation> a) { for (Class<?> i : clazz.getInterfaces()) { if (i.isAnnotationPresent(a)) return true; if (isAnnotationPresentOnInterfaces(i, a)) return true; }/*from w w w. java 2s .co m*/ return false; }
From source file:Main.java
private static void addInterfaces(Set<Class<?>> types, Class<?>[] interfaces) { for (Class<?> interfaceClass : interfaces) { types.add(interfaceClass);/* w ww.ja va 2 s. c o m*/ addInterfaces(types, interfaceClass.getInterfaces()); } }
From source file:org.apache.stratos.cartridge.agent.statistics.publisher.PluginLoader.java
private static boolean hasInterface(Class cls, Class iface) { for (Class in : cls.getInterfaces()) { if (in == iface) { return true; }//from w ww. j a v a 2 s .com } return false; }
From source file:grails.plugin.springsecurity.acl.util.ProxyUtils.java
protected static boolean isJavassistProxy(Class<?> clazz) { for (Class<?> i : clazz.getInterfaces()) { if (i.getName().contains("org.hibernate.proxy.HibernateProxy")) { return true; }// w ww .j a v a 2s . co m } return false; }
From source file:Main.java
public static Set<Class<?>> findSuperTypes(Class<?> targetClass) { Set<Class<?>> classes = new HashSet<Class<?>>(); Class<?> clazz = targetClass; while (clazz != null) { classes.add(clazz);/*from w w w .j a va2 s . c o m*/ addInterfaces(classes, clazz.getInterfaces()); clazz = clazz.getSuperclass(); } return classes; }
From source file:org.apache.ode.jacob.ChannelListener.java
private static Set<Method> getImplementedMethods(Set<Method> methods, Class clazz) { Class[] interfaces = clazz.getInterfaces(); for (int i = 0; i < interfaces.length; ++i) { if (interfaces[i] != Channel.class) { Method[] allmethods = interfaces[i].getDeclaredMethods(); for (int j = 0; j < allmethods.length; ++j) { methods.add(allmethods[j]); }//from w ww. j a v a 2 s .c o m getImplementedMethods(methods, interfaces[i]); } } return methods; }
From source file:Main.java
public static boolean isImplement(Class<?> clazz, Class<?> interfaceClazz) { if (clazz.equals(interfaceClazz)) return true; Class<?>[] ifs = clazz.getInterfaces(); for (Class<?> i : ifs) { if (i.equals(interfaceClazz)) return true; }/*from ww w . ja va 2s . c om*/ Class<?> s = clazz.getSuperclass(); if (s == null || clazz.equals(s.getClass())) return false; return isImplement(s, interfaceClazz); }
From source file:Main.java
public static boolean implementsInterface(Class<?> type, Class<?> interfaceType, boolean searchInSuperclasses) { boolean found = false; for (Class<?> item : type.getInterfaces()) { if (item.equals(interfaceType)) { found = true;//from ww w . j av a2 s .c o m break; } } if (found) { return true; } else { if (searchInSuperclasses && type.getSuperclass() != null) { return implementsInterface(type.getSuperclass(), interfaceType, searchInSuperclasses); } } return false; }
From source file:Main.java
private static void getAllIMethods(Class<?> c, List<Method> methods) { for (Method m : c.getDeclaredMethods()) methods.add(m);/* w w w . j a v a2 s. com*/ for (Class<?> i : c.getInterfaces()) { getAllIMethods(i, methods); } }
From source file:Main.java
/** * Get the interfaces for the specified class. * * @param cls the class to look up, may be <code>null</code> * @param interfacesFound the <code>Set</code> of interfaces for the class *//*ww w. ja v a 2 s . co m*/ private static void getAllInterfaces(Class cls, List interfacesFound) { while (cls != null) { Class[] interfaces = cls.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { if (!interfacesFound.contains(interfaces[i])) { interfacesFound.add(interfaces[i]); getAllInterfaces(interfaces[i], interfacesFound); } } cls = cls.getSuperclass(); } }