當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。