Polishing

(cherry picked from commit 27c2e8c)
This commit is contained in:
Juergen Hoeller
2015-12-29 21:40:20 +01:00
parent acecda7153
commit 342d760f70
9 changed files with 72 additions and 57 deletions

View File

@@ -195,7 +195,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
}
private <A extends Annotation> Collection<A> getAnnotations(AnnotatedElement ae, Class<A> annotationType) {
Collection<A> anns = new ArrayList<A>(2);
Collection<A> anns = new ArrayList<A>(1);
// look at raw annotation
A ann = ae.getAnnotation(annotationType);
@@ -211,7 +211,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
}
}
return (anns.isEmpty() ? null : anns);
return (!anns.isEmpty() ? anns : null);
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,17 +29,18 @@ import org.springframework.core.annotation.AnnotationUtils;
class BeanAnnotationHelper {
/**
* Return whether the given method is annotated directly or indirectly with @Bean.
* Return whether the given method is directly or indirectly annotated with
* the {@link Bean} annotation.
*/
public static boolean isBeanAnnotated(Method method) {
return AnnotationUtils.findAnnotation(method, Bean.class) != null;
return (AnnotationUtils.findAnnotation(method, Bean.class) != null);
}
public static String determineBeanNameFor(Method beanMethod) {
// by default the bean name is the name of the @Bean-annotated method
// By default, the bean name is the name of the @Bean-annotated method
String beanName = beanMethod.getName();
// check to see if the user has explicitly set the bean name
// Check to see if the user has explicitly set a custom bean name...
Bean bean = AnnotationUtils.findAnnotation(beanMethod, Bean.class);
if (bean != null && bean.name().length > 0) {
beanName = bean.name()[0];