本文整理汇总了Java中java.lang.reflect.AnnotatedWildcardType类的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedWildcardType类的具体用法?Java AnnotatedWildcardType怎么用?Java AnnotatedWildcardType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnnotatedWildcardType类属于java.lang.reflect包,在下文中一共展示了AnnotatedWildcardType类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: of
import java.lang.reflect.AnnotatedWildcardType; //导入依赖的package包/类
/** Create {@link JavaType} based on {@link AnnotatedType} instance. */
public static JavaType of(AnnotatedType annotatedType) {
if (annotatedType instanceof AnnotatedArrayType) {
return JavaTypes.of((AnnotatedArrayType) annotatedType);
}
if (annotatedType instanceof AnnotatedParameterizedType) {
return JavaTypes.of((AnnotatedParameterizedType) annotatedType);
}
if (annotatedType instanceof AnnotatedTypeVariable) {
return JavaTypes.of((AnnotatedTypeVariable) annotatedType);
}
if (annotatedType instanceof AnnotatedWildcardType) {
return JavaTypes.of((AnnotatedWildcardType) annotatedType);
}
// default case: use underlying raw type
JavaType result = of(annotatedType.getType());
result.getAnnotations().addAll(Annotation.of(annotatedType.getAnnotations()));
return result;
}
开发者ID:sormuras,项目名称:listing,代码行数:20,代码来源:JavaType.java
示例2: containsTypeAnnotation
import java.lang.reflect.AnnotatedWildcardType; //导入依赖的package包/类
public static boolean containsTypeAnnotation(AnnotatedType type, Class<? extends Annotation> annotation) {
if (type.isAnnotationPresent(annotation)) {
return true;
}
if (type instanceof AnnotatedParameterizedType) {
AnnotatedParameterizedType parameterizedType = ((AnnotatedParameterizedType) type);
return Arrays.stream(parameterizedType.getAnnotatedActualTypeArguments())
.anyMatch(param -> containsTypeAnnotation(param, annotation));
}
if (type instanceof AnnotatedTypeVariable) {
AnnotatedTypeVariable variable = ((AnnotatedTypeVariable) type);
return Arrays.stream(variable.getAnnotatedBounds())
.anyMatch(bound -> containsTypeAnnotation(bound, annotation));
}
if (type instanceof AnnotatedWildcardType) {
AnnotatedWildcardType wildcard = ((AnnotatedWildcardType) type);
return Stream.concat(
Arrays.stream(wildcard.getAnnotatedLowerBounds()),
Arrays.stream(wildcard.getAnnotatedUpperBounds()))
.anyMatch(param -> containsTypeAnnotation(param, annotation));
}
if (type instanceof AnnotatedArrayType) {
return containsTypeAnnotation(((AnnotatedArrayType) type).getAnnotatedGenericComponentType(), annotation);
}
return false;
}
开发者ID:leangen,项目名称:graphql-spqr,代码行数:27,代码来源:ClassUtils.java
示例3: verifyMapFieldTypeAnnotations
import java.lang.reflect.AnnotatedWildcardType; //导入依赖的package包/类
private void verifyMapFieldTypeAnnotations(Class c)
throws NoSuchFieldException, NoSuchMethodException {
Annotation anno;
AnnotatedType atBase;
AnnotatedType atParameter;
atBase = c.getDeclaredField("typeAnnotatedMap").getAnnotatedType();
anno = atBase.getAnnotations()[0];
verifyTestAnn(mapTA[0], anno, "map1");
mapTA[0] = anno;
atParameter =
((AnnotatedParameterizedType) atBase).
getAnnotatedActualTypeArguments()[0];
anno = ((AnnotatedWildcardType) atParameter).getAnnotations()[0];
verifyTestAnn(mapTA[1], anno, "map2");
mapTA[1] = anno;
anno =
((AnnotatedWildcardType) atParameter).
getAnnotatedUpperBounds()[0].getAnnotations()[0];
verifyTestAnn(mapTA[2], anno, "map3");
mapTA[2] = anno;
atParameter =
((AnnotatedParameterizedType) atBase).
getAnnotatedActualTypeArguments()[1];
anno = ((AnnotatedParameterizedType) atParameter).getAnnotations()[0];
verifyTestAnn(mapTA[3], anno, "map4");
mapTA[3] = anno;
anno =
((AnnotatedParameterizedType) atParameter).
getAnnotatedActualTypeArguments()[0].getAnnotations()[0];
verifyTestAnn(mapTA[4], anno, "map5");
mapTA[4] = anno;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:RedefineAnnotations.java
注:本文中的java.lang.reflect.AnnotatedWildcardType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论