private List<QueryConverter> getConverters(AnnotatedElement element) {
List<QueryConverter> annotatedConverters = new ArrayList<>(2);
List<Annotation> converterAnnotations = Stream.of(element.getAnnotations())
.filter(a -> a.annotationType().isAnnotationPresent(Converter.class)
|| converters.containsKey(a.annotationType()))
.collect(Collectors.toList());
if (!converterAnnotations.isEmpty()) {
for (Annotation converterAnnotation : converterAnnotations) {
QueryConverterFactory factory;
if (converters.containsKey(converterAnnotation.annotationType())) {
factory = converters.get(converterAnnotation.annotationType());
} else {
Converter converter = converterAnnotation.annotationType().getAnnotation(Converter.class);
Class<? extends QueryConverterFactory> converterFactoryClass = converter.value();
if (Converter.DEFAULT.class.isAssignableFrom(converterFactoryClass)) {
throw new QueryProxyException("Factory is not registered for annotation "
+ converterAnnotation.annotationType().getName() + "! "
+ "Set static converter using @Converter annotation value or use Queries.Builder.converter() method to register factory instance!");
}
try {
factory = converterFactoryClass.newInstance();
} catch (Exception e) {
throw new QueryProxyException(
"Problem instantiating query converter factory class with no argument constructor " + e,
e);
}
}
annotatedConverters.add(factory.get(converterAnnotation));
}
}
return annotatedConverters;
}
QueriesInvocationHandler.java 文件源码
java
阅读 32
收藏 0
点赞 0
评论 0
项目:queries
作者:
评论列表
文章目录