List of usage examples for java.lang Class getInterfaces
public Class<?>[] getInterfaces()
From source file:org.nebulaframework.core.job.archive.GridArchive.java
/** * Returns true if the given interface is a sub-interface of {@code GridJob} * marker interface./* w w w.ja v a2s . c om*/ * * @param intrface * interface to check * @return if {@code GridJob}, {@code true}, otherwise {@code false} */ private static boolean isGridJobInterface(Class<?> intrface) { for (Class<?> iface : intrface.getInterfaces()) { if (iface.getName().equals(GridJob.class.getName())) { return true; } } return false; }
From source file:Main.java
private static void _addSuperTypes(Class<?> cls, Class<?> endBefore, ArrayList<Class<?>> result, boolean addClassItself) { if (cls == endBefore || cls == null || cls == Object.class) { return;//from ww w . ja v a2 s. c o m } if (addClassItself) { if (result.contains(cls)) { // already added, no need to check supers return; } result.add(cls); } for (Class<?> intCls : cls.getInterfaces()) { _addSuperTypes(intCls, endBefore, result, true); } _addSuperTypes(cls.getSuperclass(), endBefore, result, true); }
From source file:Main.java
private static void _addSuperTypes(Class<?> cls, Class<?> endBefore, Collection<Class<?>> result, boolean addClassItself) { if (cls == endBefore || cls == null || cls == Object.class) { return;/*from w w w.j a va 2 s . c o m*/ } if (addClassItself) { if (result.contains(cls)) { // already added, no need to check supers return; } result.add(cls); } for (Class<?> intCls : cls.getInterfaces()) { _addSuperTypes(intCls, endBefore, result, true); } _addSuperTypes(cls.getSuperclass(), endBefore, result, true); }
From source file:org.geoserver.catalog.impl.ModificationProxyCloner.java
static Class getDeepestCatalogInfoInterface(CatalogInfo object) { Class<? extends CatalogInfo> sourceClass = object.getClass(); Class result = CATALOGINFO_INTERFACE_CACHE.get(sourceClass); if (result == null) { Class[] interfaces = sourceClass.getInterfaces(); // collect only CatalogInfo related interfaces List<Class> cis = new ArrayList<Class>(); for (Class clazz : interfaces) { if (CatalogInfo.class.isAssignableFrom(clazz)) { cis.add(clazz);//from w w w .ja v a 2 s.c om } } if (cis.size() == 0) { result = null; } else if (cis.size() == 1) { result = cis.get(0); } else { Collections.sort(cis, new Comparator<Class>() { @Override public int compare(Class c1, Class c2) { if (c1.isAssignableFrom(c2)) { return 1; } else if (c2.isAssignableFrom(c1)) { return -1; } else { return 0; } } }); result = cis.get(0); } CATALOGINFO_INTERFACE_CACHE.put(sourceClass, result); } return result; }
From source file:edu.usu.sdl.openstorefront.doc.EntityProcessor.java
public static List<EntityDocModel> processEntites(List<Class> entities) { List<EntityDocModel> entityDocModels = new ArrayList<>(); log.log(Level.FINEST, "Construct Entities"); for (Class entity : entities) { EntityDocModel docModel = createEntityModel(entity); addSuperClass(entity.getSuperclass(), docModel); for (Class interfaceClass : entity.getInterfaces()) { docModel.getImplementedEntities().add(createEntityModel(interfaceClass)); }/* w w w . j av a 2s .co m*/ entityDocModels.add(docModel); } entityDocModels.sort((EntityDocModel o1, EntityDocModel o2) -> o1.getName().compareTo(o2.getName())); return entityDocModels; }
From source file:org.apache.tinkerpop.gremlin.AbstractGremlinSuite.java
public static boolean isHelperMethodOverriden(final Method myMethod) { final Class<?> declaringClass = myMethod.getDeclaringClass(); for (Class<?> iface : declaringClass.getInterfaces()) { try {/*ww w. j av a 2 s. c om*/ return iface.getMethod(myMethod.getName(), myMethod.getParameterTypes()) .isAnnotationPresent(Graph.Helper.class); } catch (NoSuchMethodException ignored) { } } return false; }
From source file:com.ms.commons.test.common.ReflectUtil.java
protected static final void getInterfaces(Class<?> clazz, List<Class<?>> clazzList) { if (clazz == Object.class) { return;/*from www . j a va2 s. c om*/ } for (Class<?> c : clazz.getInterfaces()) { clazzList.add(c); } getInterfaces(clazz.getSuperclass(), clazzList); }
From source file:org.apache.hadoop.hive.metastore.RetryingRawStore.java
public static RawStore getProxy(HiveConf hiveConf, Configuration conf, String rawStoreClassName, int id) throws MetaException { Class<? extends RawStore> baseClass = (Class<? extends RawStore>) MetaStoreUtils .getClass(rawStoreClassName); RetryingRawStore handler = new RetryingRawStore(hiveConf, conf, baseClass, id); return (RawStore) Proxy.newProxyInstance(RetryingRawStore.class.getClassLoader(), baseClass.getInterfaces(), handler);// w ww .j a v a 2 s.co m }
From source file:org.apache.camel.component.cxf.util.CxfEndpointUtils.java
public static boolean hasAnnotation(Class<?> cls, Class<? extends Annotation> annotation) { if (cls == null || cls == Object.class) { return false; }//from ww w.j a v a 2 s. c o m if (null != cls.getAnnotation(annotation)) { return true; } for (Class<?> interfaceClass : cls.getInterfaces()) { if (null != interfaceClass.getAnnotation(annotation)) { return true; } } return hasAnnotation(cls.getSuperclass(), annotation); }
From source file:hermes.impl.LoaderSupport.java
/** * Indicates if a class or interface implements or extends the specified * interfaces or classes. If the specified <CODE>Class</CODE> is a class, * this method will recursively test if this class, its superclass or one of * the implemented interfaces of this class implements the specified * interface.<BR>/*from ww w . j a v a 2 s.c om*/ * If the specified <CODE>Class</CODE> is an interface, this method will * recursively test if this interface or one of the implemented interfaces of * this interface implements the specified interface.<BR> * * @param clazz * the class or interface in question * @param testInterface * the class or interface to test against * @return <CODE>true</CODE> if the specified interfaces is implemented by * this class or one of its super-classes or interfaces */ public static boolean implementsOrExtends(Class clazz, Class testInterface) { Class[] implementedInterfaces = clazz.getInterfaces(); // test interface if (clazz.equals(testInterface)) { return true; // possibly the end of the recursion } for (int i = 0; i < implementedInterfaces.length; i++) { if (implementsOrExtends(implementedInterfaces[i], testInterface)) { return true; // recursion } } // maybe the superclass implements this interface ? Class superClass = clazz.getSuperclass(); if (superClass != null && implementsOrExtends(superClass, testInterface)) { return true; // recursion } return false; }