本文整理汇总了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());
}
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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));
}
}
示例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;
}
示例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());
}
}
}
示例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());
}
}
示例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");
}
}
示例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));
}
}