List of usage examples for java.lang Class getInterfaces
public Class<?>[] getInterfaces()
From source file:eu.leads.processor.planner.ClassUtil.java
private static boolean isMatch(Class targetClass, Class loadedClass) { if (targetClass.equals(loadedClass)) { return true; }//from w w w.j a v a 2s . com Class[] classInterfaces = loadedClass.getInterfaces(); if (classInterfaces != null) { for (Class eachInterfaceClass : classInterfaces) { if (eachInterfaceClass.equals(targetClass)) { return true; } if (isMatch(targetClass, eachInterfaceClass)) { return true; } } } Class superClass = loadedClass.getSuperclass(); if (superClass != null) { if (isMatch(targetClass, superClass)) { return true; } } return false; }
From source file:org.opendaylight.netvirt.federation.plugin.identifiers.FederationPluginIdentifierRegistry.java
@SuppressWarnings("unchecked") public static String getListenerKey(LogicalDatastoreType datastoreType, Class<? extends DataObject> subtreeClass) { String listenerKey = LISTENERS.get(Pair.of(datastoreType, subtreeClass)); if (listenerKey != null) { return listenerKey; }//from ww w .j a v a 2s .co m Class<?>[] interfaces = subtreeClass.getInterfaces(); if (interfaces != null) { for (Class<?> iface : interfaces) { return getListenerKey(datastoreType, (Class<? extends DataObject>) iface); } } return null; }
From source file:GenericUtils.java
/** * Get the Generic definitions from a class for given class . * @param clz Implementing class// w ww . ja v a 2s . c om * @param class1 class with generic definition * @return null if not found */ public static Type[] getGenericDefinitons(Class clz, Class class1) { Type[] t = null; while (clz != null) { t = getGenericDefinitonsThis(clz, class1); if (t != null) return t; Class[] interfaces = clz.getInterfaces(); for (Class class2 : interfaces) { t = getGenericDefinitonsThis(class2, class1); if (t != null) return t; } clz = clz.getSuperclass(); } return t; }
From source file:bs.java
private static void loadable(String filename) { File file = new File(filename); JarInputStream is;//w w w . j a v a 2s. c o m try { ClassLoader loader = URLClassLoader.newInstance(new URL[] { file.toURI().toURL() }); is = new JarInputStream(new FileInputStream(file)); JarEntry entry; while ((entry = is.getNextJarEntry()) != null) { if (entry.getName().endsWith(".class") && !entry.getName().contains("/")) { Class<?> cls = Class.forName(FilenameUtils.removeExtension(entry.getName()), false, loader); for (Class<?> i : cls.getInterfaces()) { if (i.equals(Loadable.class)) { Loadable l = (Loadable) cls.newInstance(); Bs.addModule(l); } } } } } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:org.lunarray.model.descriptor.util.ExtensionUtil.java
/** * Gets all interfaces./*from ww w .ja v a 2 s.c o m*/ * * @param extension * The extension. * @param interfaces * The interfaces. */ private static void getAllInterfaces(final Class<?> extension, final List<Class<?>> interfaces) { for (final Class<?> inter : extension.getInterfaces()) { interfaces.add(inter); } final Class<?> superClass = extension.getSuperclass(); if (!CheckUtil.isNull(superClass)) { ExtensionUtil.getAllInterfaces(superClass, interfaces); } }
From source file:com.opensymphony.xwork2.util.AnnotationUtils.java
/** * * @param clazz The {@link Class} to inspect * @param allInterfaces list of all interfaces *//* w w w .j av a2s . c om*/ public static void addAllInterfaces(Class clazz, List<Class> allInterfaces) { if (clazz == null) { return; } Class[] interfaces = clazz.getInterfaces(); allInterfaces.addAll(Arrays.asList(interfaces)); addAllInterfaces(clazz.getSuperclass(), allInterfaces); }
From source file:org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.java
private static void visitTypes(@Nonnull Set<Class<?>> types, @Nonnull Class<?> c) { Class<?> s = c.getSuperclass(); if (s != null) { visitTypes(types, s);//from w ww . jav a2s . c o m } for (Class<?> i : c.getInterfaces()) { visitTypes(types, i); } // Visit supertypes first. types.add(c); }
From source file:com.hurence.logisland.classloading.PluginProxy.java
/** * Return all interfaces that the given class implements as a Set, * including ones implemented by superclasses. * <p>If the class itself is an interface, it gets returned as sole interface. * * @param clazz the class to analyze for interfaces * @param classLoader the ClassLoader that the interfaces need to be visible in * (may be {@code null} when accepting all declared interfaces) * @return all interfaces that the given object implements as a Set *//* w ww .j ava2s . co m*/ public static Set<Class<?>> getAllInterfacesForClassAsSet(Class<?> clazz, ClassLoader classLoader) { if (clazz.isInterface() && isVisible(clazz, classLoader)) { return Collections.<Class<?>>singleton(clazz); } Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>(); Class<?> current = clazz; while (current != null) { Class<?>[] ifcs = current.getInterfaces(); for (Class<?> ifc : ifcs) { interfaces.addAll(getAllInterfacesForClassAsSet(ifc, classLoader)); } current = current.getSuperclass(); } return interfaces; }
From source file:org.apache.tajo.util.ClassUtil.java
private static boolean isClassMatched(Class targetClass, Class loadedClass) { if (targetClass.equals(loadedClass)) { return true; }//from w w w.j a v a2 s . c o m Class[] classInterfaces = loadedClass.getInterfaces(); if (classInterfaces != null) { for (Class eachInterfaceClass : classInterfaces) { if (eachInterfaceClass.equals(targetClass)) { return true; } if (isClassMatched(targetClass, eachInterfaceClass)) { return true; } } } Class superClass = loadedClass.getSuperclass(); if (superClass != null) { if (isClassMatched(targetClass, superClass)) { return true; } } return false; }
From source file:gemlite.core.util.Util.java
public final static boolean isInterface(Class<?> c, String szInterface) { Class<?>[] face = c.getInterfaces(); for (int i = 0, j = face.length; i < j; i++) { if (face[i].getName().equals(szInterface)) { return true; } else {/*from w w w.j a v a 2 s . c o m*/ Class<?>[] face1 = face[i].getInterfaces(); for (int x = 0; x < face1.length; x++) { if (face1[x].getName().equals(szInterface)) { return true; } else if (isInterface(face1[x], szInterface)) { return true; } } } } if (null != c.getSuperclass()) { return isInterface(c.getSuperclass(), szInterface); } return false; }