當前位置: 首頁>>代碼示例>>Java>>正文


Java ReflectionUtils.getMethods方法代碼示例

本文整理匯總了Java中org.reflections.ReflectionUtils.getMethods方法的典型用法代碼示例。如果您正苦於以下問題:Java ReflectionUtils.getMethods方法的具體用法?Java ReflectionUtils.getMethods怎麽用?Java ReflectionUtils.getMethods使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.reflections.ReflectionUtils的用法示例。


在下文中一共展示了ReflectionUtils.getMethods方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUpgradeMethod

import org.reflections.ReflectionUtils; //導入方法依賴的package包/類
private Method getUpgradeMethod(DomainEvent event) {
    Class<?> providerClass = eventTypeToProvider.get(event.getClass()).getClass();

    Set<Method> methods =
            ReflectionUtils.getMethods(providerClass,
                    ReflectionUtils.withAnnotation(EventUpgrader.class),
                    ReflectionUtils.withParametersCount(1),
                    ReflectionUtils.withParameters(event.getClass()));

    if (methods.size() != 1) {
        throw new RuntimeException(
                String.format("Duplicate upgrade methods for event type %s in class %s.",
                        event.getClass(), providerClass));
    }

    return methods.stream().findFirst().get();
}
 
開發者ID:indifferen7,項目名稱:casual-eventsourcing,代碼行數:18,代碼來源:EventUpgradeService.java

示例2: supportedDomainEvents

import org.reflections.ReflectionUtils; //導入方法依賴的package包/類
Set<Class<DomainEvent>> supportedDomainEvents(Class<?> upgradeProvider) {
    Set<Method> methods =
            ReflectionUtils.getMethods(upgradeProvider,
                    ReflectionUtils.withAnnotation(EventUpgrader.class));

    if (methods.isEmpty()) {
        throw new RuntimeException(
                String.format("No event eventTypeToProvider found in class %s", upgradeProvider));
    }

    Set<Class<DomainEvent>> result = new HashSet<>();

    for (Method method : methods) {
        if (method.getParameterCount() != 1) {
            throw new RuntimeException(
                    String.format("Parameter count for upgrade method %s must be exactly one.", method));
        }

        result.add((Class<DomainEvent>) method.getParameters()[0].getType());
    }

    return result;
}
 
開發者ID:indifferen7,項目名稱:casual-eventsourcing,代碼行數:24,代碼來源:EventUpgradeService.java

示例3: findLifecycleMethod

import org.reflections.ReflectionUtils; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
private Method findLifecycleMethod(final Class lifecycleAnnotationClass) {
       Set<Method> methods = ReflectionUtils.getMethods(declaringClass, new Predicate<Method>() {
           @Override
           public boolean apply(Method input) {
               return input != null && input.getAnnotation(lifecycleAnnotationClass) != null;
           }
       });
       if (methods.isEmpty()) {
           return null;
       }
       if (methods.size() > 1) {
           throw new BootstrapException("Found multiple " + lifecycleAnnotationClass.getSimpleName() + " methods in class " + declaringClass.getSimpleName() + ". Only 1 is allowed.");
       }
       return methods.iterator().next();
   }
 
開發者ID:Kixeye,項目名稱:chassis,代碼行數:17,代碼來源:AppMetadata.java

示例4: createMethodInvokers

import org.reflections.ReflectionUtils; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
List<MethodInvoker> createMethodInvokers(Class<?> cls) {
    LambdaLocal lambdaLocal = cls.getAnnotation(LambdaLocal.class);
    if (lambdaLocal.value().length != 1) {
        throw new IllegalArgumentException(
                "@LambdaLocal must have only one value() if using with AbstractLambdaRestService");
    }
    String lambdaLocalPath = lambdaLocal.value()[0];

    Set<Method> methods = ReflectionUtils.getMethods(cls, ReflectionUtils.withAnnotation(RestMethod.class));
    return methods.stream()
            .map(method -> new MethodInvoker(cls, method, lambdaLocalPath))
            .collect(Collectors.toList());
}
 
開發者ID:tempofeng,項目名稱:lambda-local,代碼行數:15,代碼來源:AbstractLambdaRestService.java

示例5: resolvePolicyMethod

import org.reflections.ReflectionUtils; //導入方法依賴的package包/類
private Method resolvePolicyMethod(Class<?> clazz, Class<? extends Annotation> annotationClass) {
    Set<Method> methods = ReflectionUtils.getMethods(
            clazz,
            withModifier(Modifier.PUBLIC),
            withAnnotation(annotationClass));

    if (methods.isEmpty()) {
        return null;
    }

    return methods.iterator().next();
}
 
開發者ID:gravitee-io,項目名稱:gravitee-gateway,代碼行數:13,代碼來源:PolicyTest.java

示例6: findActionMethod

import org.reflections.ReflectionUtils; //導入方法依賴的package包/類
/**
 * Uses reflection to find and return the method that we later on want to invoke in our {@link #propertyChangeEx(PropertyChangeEvent)} method. The method instance searched for needs to
 * <ul>
 * <li>belong to the given <code>componentClass</code></li>
 * <li>the given name actionMethodName</li>
 * <li>have no parameter</li>
 * </ul>
 * 
 * @param componentClass
 * @param actionMethodName
 * @return
 * @throws IllegalStateException if more or less than one matching method is found.
 */
@SuppressWarnings("unchecked")
public static final <T extends Object> Method findActionMethod(final Class<T> componentClass, final String actionMethodName)
{
	Check.assumeNotNull(componentClass, "componentClass not null");
	Check.assumeNotEmpty(actionMethodName, "actionMethodName not empty");

	final Set<Method> methods = ReflectionUtils.getMethods(componentClass, new Predicate<Method>()
	{
		@Override
		public boolean apply(final Method method)
		{
			if (method.getParameterTypes().length > 0)
			{
				return false;
			}
			final String methodName = method.getName();
			if (!actionMethodName.equals(methodName))
			{
				return false;
			}

			return true;
		}
	});

	if (methods == null || methods.isEmpty())
	{
		throw new IllegalStateException("No action method found in " + componentClass + " for action name'" + actionMethodName + "'");
	}
	else if (methods.size() > 1)
	{
		throw new IllegalStateException("More then one action method found in " + componentClass + " for action name'" + actionMethodName + "': " + methods);
	}
	else
	{
		return methods.iterator().next();
	}
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:52,代碼來源:MethodActionForwardListener.java

示例7: findMethodForProperty

import org.reflections.ReflectionUtils; //導入方法依賴的package包/類
/**
 *
 * @param object
 * @param propertyName
 * @param <T>
 * @return
 */
@SuppressWarnings("unchecked")
public static <T> Optional<Method> findMethodForProperty(T object, String propertyName) {
    final Set<Method> methods = ReflectionUtils.getMethods(
        object.getClass(),
        ReflectionUtils.withModifier(Modifier.PUBLIC),
        ReflectionUtils.withName(PROPERTY_TO_METHOD_NAME.apply("set", propertyName))
    );

    return methods.size() == 1 ? methods.stream().findFirst() : Optional.empty();
}
 
開發者ID:lburgazzoli,項目名稱:lb-hazelcast,代碼行數:18,代碼來源:HzConfig.java

示例8: getDomainEventHandlerMethods

import org.reflections.ReflectionUtils; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private Set<Method> getDomainEventHandlerMethods() {
    return ReflectionUtils.getMethods(getClass(),
            ReflectionUtils.withAnnotation(DomainEventHandler.class),
            ReflectionUtils.withParametersCount(1));
}
 
開發者ID:indifferen7,項目名稱:casual-eventsourcing,代碼行數:7,代碼來源:Aggregate.java


注:本文中的org.reflections.ReflectionUtils.getMethods方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。