本文整理汇总了Java中java.lang.reflect.AnnotatedType.isAnnotationPresent方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedType.isAnnotationPresent方法的具体用法?Java AnnotatedType.isAnnotationPresent怎么用?Java AnnotatedType.isAnnotationPresent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.reflect.AnnotatedType
的用法示例。
在下文中一共展示了AnnotatedType.isAnnotationPresent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: containsTypeAnnotation
import java.lang.reflect.AnnotatedType; //导入方法依赖的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;
}
示例2: getResponsePropertySet
import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
/**
* Check whether the given <code>method</code> return type is annotated with the {@link PropertySetRef} annotation.
* @param method Method to inspect
* @return Optional {@link PropertySetRef} annotation, if available
*/
private static Optional<PropertySetRef> getResponsePropertySet(Method method) {
final AnnotatedType rt = method.getAnnotatedReturnType();
if (rt != null) {
if (rt.isAnnotationPresent(PropertySetRef.class)) {
return Optional.of(rt.getAnnotation(PropertySetRef.class));
}
// check meta-annotations
List<PropertySetRef> annotations = AnnotationUtils.getAnnotations(rt, PropertySetRef.class);
if (!annotations.isEmpty()) {
return Optional.ofNullable(annotations.get(0));
}
}
return Optional.empty();
}
示例3: getResponsePropertySetModel
import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
/**
* Check whether the given <code>method</code> return type is annotated with the {@link ApiPropertySetModel}
* annotation.
* @param method Method to inspect
* @return Optional {@link ApiPropertySetModel} annotation, if available
*/
private static Optional<ApiPropertySetModel> getResponsePropertySetModel(Method method) {
final AnnotatedType rt = method.getAnnotatedReturnType();
if (rt != null) {
if (rt.isAnnotationPresent(ApiPropertySetModel.class)) {
return Optional.of(rt.getAnnotation(ApiPropertySetModel.class));
}
// check meta-annotations
List<ApiPropertySetModel> annotations = AnnotationUtils.getAnnotations(rt, ApiPropertySetModel.class);
if (!annotations.isEmpty()) {
return Optional.ofNullable(annotations.get(0));
}
}
return Optional.empty();
}
示例4: toGraphQLType
import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public GraphQLInterfaceType toGraphQLType(String typeName, AnnotatedType javaType, Set<Type> abstractTypes, OperationMapper operationMapper, BuildContext buildContext) {
GraphQLInterfaceType.Builder typeBuilder = newInterface()
.name(typeName)
.description(buildContext.typeInfoGenerator.generateTypeDescription(javaType));
GraphQLInterface graphQLInterface = javaType.getAnnotation(GraphQLInterface.class);
List<String> fieldOrder = graphQLInterface != null ? Arrays.asList(graphQLInterface.fieldOrder()) : Collections.emptyList();
List<GraphQLFieldDefinition> fields = objectTypeMapper.getFields(javaType, fieldOrder, buildContext, operationMapper);
fields.forEach(typeBuilder::field);
typeBuilder.typeResolver(buildContext.typeResolver);
GraphQLInterfaceType type = new MappedGraphQLInterfaceType(typeBuilder.build(), javaType);
if (javaType.isAnnotationPresent(GraphQLInterface.class)) {
GraphQLInterface meta = javaType.getAnnotation(GraphQLInterface.class);
if (meta.implementationAutoDiscovery()) {
String[] scanPackages = meta.scanPackages();
if (scanPackages.length == 0 && Utils.arrayNotEmpty(buildContext.basePackages)) {
scanPackages = buildContext.basePackages;
}
ClassUtils.findImplementations(javaType, scanPackages).forEach(impl ->
getImplementingType(impl, abstractTypes, operationMapper, buildContext)
.ifPresent(implType -> buildContext.typeRepository.registerDiscoveredCovariantType(type.getName(), impl, implType)));
}
}
return type;
}
示例5: supports
import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supports(AnnotatedType type) {
return type.isAnnotationPresent(GraphQLUnion.class)
|| ClassUtils.getRawType(type.getType()).isAnnotationPresent(GraphQLUnion.class);
}
示例6: supports
import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supports(AnnotatedType type) {
return type.isAnnotationPresent(GraphQLRootContext.class);
}
示例7: supports
import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supports(AnnotatedType type) {
return type.isAnnotationPresent(GraphQLContext.class);
}
示例8: supports
import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supports(AnnotatedType type) {
return type.isAnnotationPresent(GraphQLId.class);
}
示例9: supports
import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supports(AnnotatedType type) {
return type.isAnnotationPresent(GraphQLEnvironment.class);
}
示例10: supports
import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supports(AnnotatedType type) {
return type.isAnnotationPresent(GraphQLScalar.class);
}
示例11: supportsInterface
import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supportsInterface(AnnotatedType interfase) {
return interfase.isAnnotationPresent(GraphQLInterface.class);
}