当前位置: 首页>>代码示例>>Java>>正文


Java ClassUtils.getAllInterfaces方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.ClassUtils.getAllInterfaces方法的典型用法代码示例。如果您正苦于以下问题:Java ClassUtils.getAllInterfaces方法的具体用法?Java ClassUtils.getAllInterfaces怎么用?Java ClassUtils.getAllInterfaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.ClassUtils的用法示例。


在下文中一共展示了ClassUtils.getAllInterfaces方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAnnotatedPublicMethods

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * 找出所有标注了该annotation的公共方法(含父类的公共函数),循环其接口.
 * 
 * 暂未支持Spring风格Annotation继承Annotation
 * 
 * 另,如果子类重载父类的公共函数,父类函数上的annotation不会继承,只有接口上的annotation会被继承.
 */
public static <T extends Annotation> Set<Method> getAnnotatedPublicMethods(Class<?> clazz, Class<T> annotation) {
	// 已递归到Objebt.class, 停止递归
	if (Object.class.equals(clazz)) {
		return Collections.emptySet();
	}

	List<Class<?>> ifcs = ClassUtils.getAllInterfaces(clazz);
	Set<Method> annotatedMethods = new HashSet<Method>();

	// 遍历当前类的所有公共方法
	Method[] methods = clazz.getMethods();

	for (Method method : methods) {
		// 如果当前方法有标注,或定义了该方法的所有接口有标注
		if (method.getAnnotation(annotation) != null || searchOnInterfaces(method, annotation, ifcs)) {
			annotatedMethods.add(method);
		}
	}

	return annotatedMethods;
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:29,代码来源:ClassUtil.java

示例2: isOfType

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
public static <T extends Model> boolean isOfType(Class<T> modelClass, String fqn) {
    if (modelClass == null)
        return false;

    Class<T> clazz = getModelInterface(modelClass);

    if (clazz != null && clazz.getName().equals(fqn))
        return true;

    List<Class<?>> interfaces = ClassUtils.getAllInterfaces(modelClass);

    if (interfaces != null && !interfaces.isEmpty()) {
        for (Class<?> interf : interfaces) {
            if (interf.getName().equals(fqn))
                return true;
        }
    }

    return false;
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:21,代码来源:Reflect.java

示例3: scanForExampleModels

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
protected void scanForExampleModels(Object o) {
    List<Class<?>> classesToScan = ClassUtils.getAllInterfaces(o.getClass());
    classesToScan.add(o.getClass());
    for (Class<?> scanMe : classesToScan) {
        for (Method m : scanMe.getMethods()) {
            ExampleModel exampleModel = m.getAnnotation(ExampleModel.class);
            if (exampleModel != null) {
                if (!isStatic(m.getModifiers()) || !isPublic(m.getModifiers())) {
                    throw new IllegalArgumentException(
                            "@ExampleModel annotation may only be applied to public static method, not " + m);
                }
                Class modelClass = m.getReturnType();
                modelClassToExampleFactoryMethods.put(modelClass, m);
            }
        }
    }
}
 
开发者ID:dnault,项目名称:therapi-json-rpc,代码行数:18,代码来源:MethodRegistry.java

示例4: getSimpleInterfaceName

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private static String getSimpleInterfaceName(Class<?> basicImplClass) {
    List<Class<?>> list = ClassUtils.getAllInterfaces(basicImplClass);
    for (Class interfaceImplemented : list) {
        if (!interfaceImplemented.getSimpleName().equals("LoadAcceptor"))
            return interfaceImplemented.getSimpleName();
    }
    return "LoadAcceptor";
}
 
开发者ID:tapack,项目名称:satisfy,代码行数:9,代码来源:EmailSpiFactory.java

示例5: createSyncronized

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * enables Webdriver usage of the same from different threads (handles locks internally). This locks an already in use instance.
 * <p/>
 * <i>Difference to <tt>ThreadGuard</tt>:</i> It does not forbid usage of a single webdriver by different threads.
 * <p/>
 * based on {@link org.openqa.selenium.support.ThreadGuard}
 */
public static WebDriver createSyncronized(WebDriver webDriver) {
    ClassLoader       classLoader       = webDriver.getClass().getClassLoader();
    List<Class<?>>    interfaces        = ClassUtils.getAllInterfaces(webDriver.getClass());
    InvocationHandler invocationHandler = new SynchronizedWebDriverInvocationHandler(webDriver);

    return (WebDriver) Proxy.newProxyInstance(classLoader,
                                              interfaces.toArray(new Class[interfaces.size()]),
                                              invocationHandler);
}
 
开发者ID:lkwg82,项目名称:de.lgohlke.selenium-webdriver,代码行数:17,代码来源:ConcurrentWebDriverFactory.java

示例6: getAllInterfaces

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * 递归返回本类及所有基类继承的接口,及接口继承的接口,比Spring中的相同实现完整
 */
public static List<Class<?>> getAllInterfaces(final Class<?> cls) {
	return ClassUtils.getAllInterfaces(cls);
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:7,代码来源:ClassUtil.java

示例7: createLocking

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * adds capability to lock your webDriver instance, suitable for concurrent usage
 * <p/>
 * <pre>
 *      LockingWebDriver lockingDriver = ConcurrentWebDriverFactory.createLocking(webDriver);
 *
 *      // blocking any other locking request
 *      lockingDriver.lock();
 *
 *      lockingDriver.get("http://www.lgohlke.de");
 *
 *      lockingDriver.unlock();
 * </pre>
 */
public static LockingWebDriver createLocking(WebDriver webDriver) {
    ClassLoader    classLoader = webDriver.getClass().getClassLoader();
    List<Class<?>> interfaces  = ClassUtils.getAllInterfaces(webDriver.getClass());
    interfaces.add(LockingWebDriver.class);
    InvocationHandler invocationHandler = new LockingWebDriverInvocationHandler(webDriver);

    return (LockingWebDriver) Proxy.newProxyInstance(classLoader,
                                                     interfaces.toArray(new Class[interfaces.size()]),
                                                     invocationHandler);
}
 
开发者ID:lkwg82,项目名称:de.lgohlke.selenium-webdriver,代码行数:25,代码来源:ConcurrentWebDriverFactory.java

示例8: isSubclass

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * <p>
 * isSubclass
 * </p>
 * 
 * @param superclass
 *            a {@link java.lang.reflect.Type} object.
 * @param subclass
 *            a {@link java.lang.reflect.Type} object.
 * @return a boolean.
 */
public static boolean isSubclass(Type superclass, Type subclass) {
	List<Class<?>> superclasses = ClassUtils.getAllSuperclasses((Class<?>) subclass);
	List<Class<?>> interfaces = ClassUtils.getAllInterfaces((Class<?>) subclass);
	if (superclasses.contains(superclass) || interfaces.contains(superclass)) {
		return true;
	}

	return false;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:21,代码来源:GenericClass.java


注:本文中的org.apache.commons.lang3.ClassUtils.getAllInterfaces方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。