/** * Create a new {@link AnnotationTypeFilter} for the given annotation type. * @param annotationType the annotation type to match * @param considerMetaAnnotations whether to also match on meta-annotations * @param considerInterfaces whether to also match interfaces */ public AnnotationTypeFilter( Class<? extends Annotation> annotationType, boolean considerMetaAnnotations, boolean considerInterfaces) { super(annotationType.isAnnotationPresent(Inherited.class), considerInterfaces); this.annotationType = annotationType; this.considerMetaAnnotations = considerMetaAnnotations; }
private static <T> boolean withExtensionAnnotation(Class<T> type) { return type.isAnnotationPresent(SPI.class); }
private static <T> boolean withExtensionAnnotation(Class<T> type) { return type.isAnnotationPresent(SPI.class); }
/** Returns true if the supplied class includes an annotation of the given type. */ static public boolean isAnnotationPresent (Class c, Class<? extends java.lang.annotation.Annotation> annotationType) { return c.isAnnotationPresent(annotationType); }
/** Returns true if the supplied class includes an annotation of the given type. */ static public boolean isAnnotationPresent (Class c, Class<? extends java.lang.annotation.Annotation> annotationType) { return c.isAnnotationPresent(annotationType); }
/** * Checks whether the given annotation type is a recognized qualifier type. */ protected boolean isQualifier(Class<? extends Annotation> annotationType) { for (Class<? extends Annotation> qualifierType : this.qualifierTypes) { if (annotationType.equals(qualifierType) || annotationType.isAnnotationPresent(qualifierType)) { return true; } } return false; }
private static boolean hasConstraintParameter(Method method) { Annotation[][] parameterAnnotations = method.getParameterAnnotations(); if (parameterAnnotations != null && parameterAnnotations.length > 0) { for (Annotation[] annotations : parameterAnnotations) { for (Annotation annotation : annotations) { if (annotation.annotationType().isAnnotationPresent(Constraint.class)) { return true; } } } } return false; }
private static boolean hasConstraintParameter(Method method) { Annotation[][] parameterAnnotations = method.getParameterAnnotations(); if (parameterAnnotations != null && parameterAnnotations.length > 0) { for (Annotation[] annotations : parameterAnnotations) { for (Annotation annotation : annotations) { if (annotation.annotationType().isAnnotationPresent(Constraint.class)) { return true; } } } } return false; }
@Override public boolean canRead(Class<?> clazz, @Nullable MediaType mediaType) { return (clazz.isAnnotationPresent(XmlRootElement.class) || clazz.isAnnotationPresent(XmlType.class)) && canRead(mediaType); }
private static Set<? extends Annotation> jsonAnnotations(Annotation[] annotations) { Set<Annotation> result = null; for (Annotation annotation : annotations) { if (annotation.annotationType().isAnnotationPresent(JsonQualifier.class)) { if (result == null) result = new LinkedHashSet<>(); result.add(annotation); } } return result != null ? unmodifiableSet(result) : Collections.<Annotation>emptySet(); } }
@Override public boolean canEncode(ResolvableType elementType, @Nullable MimeType mimeType) { if (super.canEncode(elementType, mimeType)) { Class<?> outputClass = elementType.toClass(); return (outputClass.isAnnotationPresent(XmlRootElement.class) || outputClass.isAnnotationPresent(XmlType.class)); } else { return false; } }
@Override public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType) { Class<?> outputClass = elementType.toClass(); return (outputClass.isAnnotationPresent(XmlRootElement.class) || outputClass.isAnnotationPresent(XmlType.class)) && super.canDecode(elementType, mimeType); }
@Override public boolean matches(Class<?> clazz) { return (this.checkInherited ? AnnotatedElementUtils.hasAnnotation(clazz, this.annotationType) : clazz.isAnnotationPresent(this.annotationType)); }
@Override public @Nullable Converter<ResponseBody, ?> responseBodyConverter( Type type, Annotation[] annotations, Retrofit retrofit) { if (type instanceof Class && ((Class<?>) type).isAnnotationPresent(XmlRootElement.class)) { return new JaxbResponseConverter<>(contextForType((Class<?>) type), (Class<?>) type); } return null; }
@Override public @Nullable Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) { if (type instanceof Class && ((Class<?>) type).isAnnotationPresent(XmlRootElement.class)) { return new JaxbRequestConverter<>(contextForType((Class<?>) type), (Class<?>) type); } return null; }
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) { return FastJsonHttpMessageConverter.class.isAssignableFrom(converterType) && (returnType.getContainingClass().isAnnotationPresent(ResponseJSONP.class) || returnType.hasMethodAnnotation(ResponseJSONP.class)); }
@Override public <T> T getExtension(Class<T> type, String name) { if (type.isInterface() && type.isAnnotationPresent(SPI.class)) { ExtensionLoader<T> loader = ExtensionLoader.getExtensionLoader(type); if (!loader.getSupportedExtensions().isEmpty()) { return loader.getAdaptiveExtension(); } } return null; }
@Override public <T> T getExtension(Class<T> type, String name) { if (type.isInterface() && type.isAnnotationPresent(SPI.class)) { ExtensionLoader<T> loader = ExtensionLoader.getExtensionLoader(type); if (!loader.getSupportedExtensions().isEmpty()) { return loader.getAdaptiveExtension(); } } return null; }
private Object unmarshal(List<XMLEvent> events, Class<?> outputClass) { try { Unmarshaller unmarshaller = initUnmarshaller(outputClass); XMLEventReader eventReader = StaxUtils.createXMLEventReader(events); if (outputClass.isAnnotationPresent(XmlRootElement.class)) { return unmarshaller.unmarshal(eventReader); } else { JAXBElement<?> jaxbElement = unmarshaller.unmarshal(eventReader, outputClass); return jaxbElement.getValue(); } } catch (UnmarshalException ex) { throw new DecodingException("Could not unmarshal XML to " + outputClass, ex); } catch (JAXBException ex) { throw new CodecException("Invalid JAXB configuration", ex); } }
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (isLogEnabled()) { String[] beanNames = beanFactory.getBeanDefinitionNames(); for (String beanName : beanNames) { String nameToLookup = beanName; if (beanFactory.isFactoryBean(beanName)) { nameToLookup = BeanFactory.FACTORY_BEAN_PREFIX + beanName; } Class<?> beanType = beanFactory.getType(nameToLookup); if (beanType != null) { Class<?> userClass = ClassUtils.getUserClass(beanType); if (userClass.isAnnotationPresent(Deprecated.class)) { BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName); logDeprecatedBean(beanName, beanType, beanDefinition); } } } } }