Java Code Examples for java.lang.reflect.AnnotatedType#isAnnotationPresent()
The following examples show how to use
java.lang.reflect.AnnotatedType#isAnnotationPresent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassUtils.java From graphql-spqr with Apache License 2.0 | 6 votes |
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)); } return type instanceof AnnotatedArrayType && containsTypeAnnotation(((AnnotatedArrayType) type).getAnnotatedGenericComponentType(), annotation); }
Example 2
Source File: TypeInfo.java From smallrye-graphql with Apache License 2.0 | 5 votes |
public boolean isNonNull() { if (ifClass(c -> c.isAnnotationPresent(NonNull.class))) return true; // TODO test if (!container.isCollection()) return false; // TODO test // TODO this is not generally correct AnnotatedType annotatedArg = container.annotatedArgs[0]; return annotatedArg.isAnnotationPresent(NonNull.class); }
Example 3
Source File: ObjectScalarMapper.java From graphql-spqr with Apache License 2.0 | 4 votes |
@Override public boolean supports(AnnotatedElement element, AnnotatedType type) { return type.isAnnotationPresent(GraphQLScalar.class) || Object.class.equals(type.getType()) || ClassUtils.isSuperClass(Map.class, type); }
Example 4
Source File: UnionTypeMapper.java From graphql-spqr with Apache License 2.0 | 4 votes |
@Override public boolean supports(AnnotatedElement element, AnnotatedType type) { return type.isAnnotationPresent(GraphQLUnion.class) || ClassUtils.getRawType(type.getType()).isAnnotationPresent(GraphQLUnion.class); }
Example 5
Source File: MapToListTypeAdapter.java From graphql-spqr with Apache License 2.0 | 4 votes |
@Override public boolean supports(AnnotatedType type) { return ClassUtils.isSuperClass(Map.class, type) && !type.isAnnotationPresent(GraphQLScalar.class); }
Example 6
Source File: InterfaceMapper.java From graphql-spqr with Apache License 2.0 | 4 votes |
@SuppressWarnings("WeakerAccess") protected boolean isImplementationAutoDiscoveryEnabled(AnnotatedType javaType) { return javaType.isAnnotationPresent(GraphQLInterface.class) && javaType.getAnnotation(GraphQLInterface.class).implementationAutoDiscovery(); }
Example 7
Source File: InterfaceMapper.java From graphql-spqr with Apache License 2.0 | 4 votes |
@SuppressWarnings("WeakerAccess") protected String[] getScanPackages(AnnotatedType javaType) { return javaType.isAnnotationPresent(GraphQLInterface.class) ? javaType.getAnnotation(GraphQLInterface.class).scanPackages() : Utils.emptyArray(); }
Example 8
Source File: IdAdapter.java From graphql-spqr with Apache License 2.0 | 4 votes |
@Override public boolean supports(AnnotatedType type) { return type.isAnnotationPresent(GraphQLId.class); }
Example 9
Source File: IdAdapter.java From graphql-spqr with Apache License 2.0 | 4 votes |
@Override public boolean supports(AnnotatedType type, Parameter parameter) { return type.isAnnotationPresent(GraphQLId.class) || (parameter != null && parameter.isAnnotationPresent(GraphQLId.class)); }
Example 10
Source File: AnnotatedInterfaceStrategy.java From graphql-spqr with Apache License 2.0 | 4 votes |
@Override public boolean supportsInterface(AnnotatedType inter) { return inter.isAnnotationPresent(GraphQLInterface.class); }