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


Java AnnotatedType.isAnnotationPresent方法代码示例

本文整理汇总了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;
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:27,代码来源:ClassUtils.java

示例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();
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:20,代码来源:PropertyBoxSwaggerExtension.java

示例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();
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:21,代码来源:PropertyBoxSwaggerExtension.java

示例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;
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:30,代码来源:InterfaceMapper.java

示例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);
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:6,代码来源:UnionTypeMapper.java

示例6: supports

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supports(AnnotatedType type) {
    return type.isAnnotationPresent(GraphQLRootContext.class);
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:5,代码来源:RootContextInjector.java

示例7: supports

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supports(AnnotatedType type) {
    return type.isAnnotationPresent(GraphQLContext.class);
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:5,代码来源:ContextInjector.java

示例8: supports

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supports(AnnotatedType type) {
    return type.isAnnotationPresent(GraphQLId.class);
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:5,代码来源:IdAdapter.java

示例9: supports

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supports(AnnotatedType type) {
    return type.isAnnotationPresent(GraphQLEnvironment.class);
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:5,代码来源:EnvironmentInjector.java

示例10: supports

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supports(AnnotatedType type) {
    return type.isAnnotationPresent(GraphQLScalar.class);
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:5,代码来源:AnnotatedScalarStrategy.java

示例11: supportsInterface

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
@Override
public boolean supportsInterface(AnnotatedType interfase) {
    return interfase.isAnnotationPresent(GraphQLInterface.class);
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:5,代码来源:AnnotatedInterfaceStrategy.java


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