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


Java AnnotatedParameter.isAnnotationPresent方法代码示例

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


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

示例1: checkMultipleAnnotationParameter

import javax.enterprise.inject.spi.AnnotatedParameter; //导入方法依赖的package包/类
/**
 * Checks if any property resolver method parameter is annotated with 
 * more than one of the following: {@link PropertyKey}, {@link PropertyBundle}, 
 * {@link PropertyLocale}
 */
private void checkMultipleAnnotationParameter() {
    int count;
    for (final AnnotatedParameter<?> parameter : propertyResolverMethod.getParameters()) {
        count = 0;
        if (parameter.isAnnotationPresent(PropertyKey.class)) {
            count++;
        }
        if (parameter.isAnnotationPresent(PropertyBundle.class)) {
            count++;
        }
        if (parameter.isAnnotationPresent(PropertyLocale.class)) {
            count++;
        }
        if (count > 1) {
            throw new ExtensionInitializationException(
                    "A property resolver method parameter must not be annotated with more than one of the following: "
                            + PropertyKey.class.getSimpleName() + ", " + PropertyBundle.class.getSimpleName()
                            + " or " + PropertyLocale.class.getSimpleName());
        }
    }
}
 
开发者ID:gonmarques,项目名称:cdi-properties,代码行数:27,代码来源:PropertyResolverMethodParametersVerifier.java

示例2: isHandler

import javax.enterprise.inject.spi.AnnotatedParameter; //导入方法依赖的package包/类
/**
 * Determines if the given method is a handler by looking for the {@link Handles} annotation on a parameter.
 *
 * @param method method to search
 * @return true if {@link Handles} is found, false otherwise
 */
public static boolean isHandler(final AnnotatedMethod<?> method)
{
    if (method == null)
    {
        throw new IllegalArgumentException("Method must not be null");
    }

    for (AnnotatedParameter<?> param : method.getParameters())
    {
        if (param.isAnnotationPresent(Handles.class) || param.isAnnotationPresent(BeforeHandles.class))
        {
            return true;
        }
    }

    return false;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:24,代码来源:HandlerMethodImpl.java

示例3: findHandlerParameter

import javax.enterprise.inject.spi.AnnotatedParameter; //导入方法依赖的package包/类
public static AnnotatedParameter<?> findHandlerParameter(final AnnotatedMethod<?> method)
{
    if (!isHandler(method))
    {
        throw new IllegalArgumentException("Method is not a valid handler");
    }

    AnnotatedParameter<?> returnParam = null;

    for (AnnotatedParameter<?> param : method.getParameters())
    {
        if (param.isAnnotationPresent(Handles.class) || param.isAnnotationPresent(BeforeHandles.class))
        {
            returnParam = param;
            break;
        }
    }

    return returnParam;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:21,代码来源:HandlerMethodImpl.java

示例4: get

import javax.enterprise.inject.spi.AnnotatedParameter; //导入方法依赖的package包/类
@Override
public Publisher<T> get(Object event) {
    CDI<Object> cdi = CDI.current();
    List<InstanceHolder> instanceHolders = new ArrayList<>();
    List<Object> parameters = new ArrayList<>();
    for(AnnotatedParameter<?> ap : annotatedMethod.getParameters()) {
        if(ap.isAnnotationPresent(ObservesReactor.class)) {
            parameters.add(event);
        } else {
            InstanceHolder holder = getReference(cdi, ap.getJavaParameter().getType(), ap.getAnnotations());
            instanceHolders.add(holder);
            parameters.add(holder.instance);
        }
    }
    InstanceHolder eventReceiver = getReference(cdi,annotatedType.getJavaClass(),
            findQualifiers(annotatedType.getAnnotations()));
    Object[] params = parameters.toArray();
    try {
        Object result = targetMethod.invoke(eventReceiver.instance, params);
        if(returnsPublisher) {
            return (Publisher<T>) result;
        } else {
            return Mono.just((T)result).doAfterTerminate(() -> instanceHolders.forEach(InstanceHolder::destroy));
        }
    } catch (IllegalAccessException | InvocationTargetException e) {
        return Mono.fromSupplier(() -> { throw new RuntimeException(e); });
    } finally {
        eventReceiver.destroy();
    }
}
 
开发者ID:johnament,项目名称:reactive-cdi-events,代码行数:31,代码来源:ReactorObserverRegistry.java

示例5: hasEventParameter

import javax.enterprise.inject.spi.AnnotatedParameter; //导入方法依赖的package包/类
private boolean hasEventParameter(AnnotatedMethod<?> annotatedMethod) {
    for (AnnotatedParameter<?> param : annotatedMethod.getParameters()) {
        if (param.isAnnotationPresent(Observes.class)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:weld,项目名称:weld-vertx,代码行数:9,代码来源:RouteExtension.java

示例6: of

import javax.enterprise.inject.spi.AnnotatedParameter; //导入方法依赖的package包/类
private String of(AnnotatedParameter<?> parameter) {
    if (parameter.isAnnotationPresent(Metric.class)) {
        Metric metric = parameter.getAnnotation(Metric.class);
        String name = (metric.name().isEmpty()) ? getParameterName(parameter) : of(metric.name());
        return metric.absolute() | parameters.contains(MetricsParameter.useAbsoluteName) ? name : MetricRegistry.name(parameter.getDeclaringCallable().getJavaMember().getDeclaringClass(), name);
    } else {
        return parameters.contains(MetricsParameter.useAbsoluteName) ? getParameterName(parameter) : MetricRegistry.name(parameter.getDeclaringCallable().getJavaMember().getDeclaringClass(), getParameterName(parameter));
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:10,代码来源:SeMetricName.java

示例7: extract

import javax.enterprise.inject.spi.AnnotatedParameter; //导入方法依赖的package包/类
/**
 * see {@link ResolverParameterExtractor#extract(AnnotatedParameter)}
 */
@Override
public T extract(AnnotatedParameter<?> parameter) {
    if (parameter.isAnnotationPresent(parameterType)) {
        return resolverParameter;
    }
    return null;
}
 
开发者ID:gonmarques,项目名称:cdi-properties,代码行数:11,代码来源:ProvidedResolverParameterExtractor.java

示例8: checkLocaleResolverParameterAnnotations

import javax.enterprise.inject.spi.AnnotatedParameter; //导入方法依赖的package包/类
/**
 * Checks if any property resolver method parameter is annotated with 
 * {@link PropertyLocale}
 */
private void checkLocaleResolverParameterAnnotations() {
    for (final AnnotatedParameter<?> parameter : localeResolverMethod.getParameters()) {
        if (parameter.isAnnotationPresent(PropertyLocale.class)) {
            throw new ExtensionInitializationException(
                    "A Locale resolver method parameter must not be annotated with: "
                            + PropertyLocale.class.getSimpleName());
        }
    }
}
 
开发者ID:gonmarques,项目名称:cdi-properties,代码行数:14,代码来源:LocaleResolverMethodParametersVerifier.java

示例9: checkPropertyKeyExists

import javax.enterprise.inject.spi.AnnotatedParameter; //导入方法依赖的package包/类
/**
 * Checks if there is at least one property resolver method parameter annotated with {@link PropertyKey}
 */
private void checkPropertyKeyExists() {
    boolean foundKeyProperty = false;
    for (final AnnotatedParameter<?> parameter : propertyResolverMethod.getParameters()) {
        if (parameter.isAnnotationPresent(PropertyKey.class)) {
            foundKeyProperty = true;
            break;
        }
    }
    if (!foundKeyProperty) {
        throw new ExtensionInitializationException(
                "At least one parameter of the custom property resolver must represent de property key, annotated with "
                        + PropertyKey.class.getName());
    }
}
 
开发者ID:gonmarques,项目名称:cdi-properties,代码行数:18,代码来源:PropertyResolverMethodParametersVerifier.java

示例10: checkRepeatedParameterType

import javax.enterprise.inject.spi.AnnotatedParameter; //导入方法依赖的package包/类
/**
 * Checks if the given parameter type exists in more than a single property resolver
 * method parameter
 * @param annotation
 *            The parameter type being checked
 */
private void checkRepeatedParameterType(Class<? extends Annotation> annotation) {
    int count = 0;
    for (final AnnotatedParameter<?> parameter : propertyResolverMethod.getParameters()) {
        if (parameter.isAnnotationPresent(annotation)) {
            count++;
        }
    }
    if (count > 1) {
        throw new ExtensionInitializationException("There must be only a single param annotated with "
                + annotation.getSimpleName() + " in the property resolver method");
    }
}
 
开发者ID:gonmarques,项目名称:cdi-properties,代码行数:19,代码来源:PropertyResolverMethodParametersVerifier.java

示例11: of

import javax.enterprise.inject.spi.AnnotatedParameter; //导入方法依赖的package包/类
private String of(AnnotatedParameter<?> parameter) {
    if (parameter.isAnnotationPresent(Metric.class)) {
        Metric metric = parameter.getAnnotation(Metric.class);
        String name = (metric.name().isEmpty()) ? getParameterName(parameter) : of(metric.name());
        return metric.absolute() | parameters.contains(useAbsoluteName) ? name : MetricRegistry.name(parameter.getDeclaringCallable().getJavaMember().getDeclaringClass(), name);
    } else {
        return parameters.contains(useAbsoluteName) ? getParameterName(parameter) : MetricRegistry.name(parameter.getDeclaringCallable().getJavaMember().getDeclaringClass(), getParameterName(parameter));
    }
}
 
开发者ID:astefanutti,项目名称:metrics-cdi,代码行数:10,代码来源:SeMetricName.java


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