List of usage examples for java.lang Class getInterfaces
public Class<?>[] getInterfaces()
From source file:Main.java
/** * Gets the given class's {@link Field}s marked with the annotation of the * specified class./* w ww. j a v a 2 s. co m*/ * <p> * Unlike {@link Class#getFields()}, the result will include any non-public * fields, including fields defined in supertypes of the given class. * </p> * * @param c The class to scan for annotated fields. * @param annotationClass The type of annotation for which to scan. * @param fields The list to which matching fields will be added. */ public static <A extends Annotation> void getAnnotatedFields(final Class<?> c, final Class<A> annotationClass, final List<Field> fields) { if (c == null) return; // check supertypes for annotated fields first getAnnotatedFields(c.getSuperclass(), annotationClass, fields); for (final Class<?> iface : c.getInterfaces()) { getAnnotatedFields(iface, annotationClass, fields); } for (final Field f : c.getDeclaredFields()) { final A ann = f.getAnnotation(annotationClass); if (ann != null) fields.add(f); } }
From source file:com.github.juanmf.java2plant.Parser.java
protected static void addImplementations(Set<Relation> relations, Class<?> fromType) { Class<?>[] interfaces = fromType.getInterfaces(); for (Class<?> i : interfaces) { Relation anImplements = new Implementation(fromType, i.getName()); relations.add(anImplements);// www.j av a2s .c om } }
From source file:com.bstek.dorado.common.event.ClientEventRegistry.java
private static void collectClientEventRegisterInfos(Map<String, ClientEventRegisterInfo> eventMap, Class<?> type) { Class<?> superType = type.getSuperclass(); if (superType != null) { collectClientEventRegisterInfos(eventMap, superType); }//from w w w .j ava2 s . c o m Class<?>[] interfaces = type.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { Class<?> interfaceType = interfaces[i]; collectClientEventRegisterInfos(eventMap, interfaceType); } collectClientEventRegisterInfosFromSingleType(type); Map<String, ClientEventRegisterInfo> selfEventMap = typeMap.get(type); if (selfEventMap != null) { eventMap.putAll(selfEventMap); } }
From source file:org.geoserver.cluster.integration.IntegrationTestsUtils.java
/** * Helper method that find the interface of an implementation. *///from www . j a v a 2 s .c om private static Class<?> getInfoInterface(Class<?> type) { Class<?>[] classInterfaces = type.getInterfaces(); for (Class<?> classInterface : classInterfaces) { if (Info.class.isAssignableFrom(classInterface)) { // compatible interface found, let's use this one return classInterface; } } // no compatible interface found return Info.class; }
From source file:org.psikeds.common.config.ServletContextProxy.java
private static Object createProxy(final ServletContext ctx) { // Get runtime class of CTX which is something that implements // ServletContext final Class<? extends ServletContext> clazz = ctx.getClass(); // Get the Classloader for that runtime class final ClassLoader loader = getClassloader(clazz); // Create a new Proxy for that Class using our ServletContextProxy return Proxy.newProxyInstance(loader, clazz.getInterfaces(), new ServletContextProxy(ctx)); }
From source file:com.espertech.esper.event.bean.PropertyHelper.java
private static void getImplementedInterfaceParents(Class clazz, Set<Class> classesResult) { Class[] interfaces = clazz.getInterfaces(); if (interfaces == null) { return;//w ww. j a v a 2 s .c o m } for (int i = 0; i < interfaces.length; i++) { classesResult.add(interfaces[i]); getImplementedInterfaceParents(interfaces[i], classesResult); } }
From source file:org.kawanfw.file.servlet.ServerUserThrowable.java
/** * Says if a class is a Commons Configurator * //from ww w . j a v a2 s. co m * @param theClass * @return */ private static boolean DoesClassImplementsAConfigurator(Class<?> theClass) { boolean iscommonsConfigurator = false; if (theClass != null) { Class<?>[] interfaces = theClass.getInterfaces(); if (interfaces == null) { return iscommonsConfigurator; } for (int i = 0; i < interfaces.length; i++) { Class<?> theInterface = interfaces[i]; String interfaceName = theInterface.getName(); debug("interfaceName: " + interfaceName); if (interfaceName.equals("org.kawanfw.commons.api.server.CommonsConfigurator") || interfaceName.equals("org.kawanfw.file.api.server.FileConfigurator") // || interfaceName // .equals("org.kawanfw.file.api.server.fileaction.FileActionManager") || interfaceName.equals("org.kawanfw.sql.api.server.SqlConfigurator") ) { iscommonsConfigurator = true; break; } } } return iscommonsConfigurator; }
From source file:jfix.util.Reflections.java
/** * Returns all interfaces and superclasses implemented by a given class. */// w ww . ja v a 2 s . c o m public static Set<Class<?>> getSuperClassesAndInterfaces(Class<?> clazz) { Set<Class<?>> result = new HashSet<>(); if (clazz != null) { result.add(clazz); for (Class<?> interfaceClass : clazz.getInterfaces()) { result.addAll(getSuperClassesAndInterfaces(interfaceClass)); } result.addAll(getSuperClassesAndInterfaces(clazz.getSuperclass())); } return result; }
From source file:com.github.juanmf.java2plant.Parser.java
private static void addInterfaces(Class<?> c, Set<Class<?>> newClasses) { Class<?>[] interfaces = c.getInterfaces(); for (Class<?> i : interfaces) { newClasses.add(i);//from w w w . j a v a 2 s . c o m addInterfaces(i, newClasses); } }
From source file:MBeanTyper.java
/** * create a typed object from an mbean/*from ww w .ja v a2 s. c o m*/ */ public static final Object typeMBean(MBeanServer server, ObjectName mbean, Class mainInterface) throws Exception { List interfaces = new ArrayList(); if (mainInterface.isInterface()) { interfaces.add(mainInterface); } addInterfaces(mainInterface.getInterfaces(), interfaces); Class cl[] = (Class[]) interfaces.toArray(new Class[interfaces.size()]); if (DEBUG) { System.err .println("typeMean->server=" + server + ",mbean=" + mbean + ",mainInterface=" + mainInterface); for (int c = 0; c < cl.length; c++) { System.err.println(" :" + cl[c]); } } return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), cl, new MBeanTyperInvoker(server, mbean)); }