Polishing
This commit is contained in:
@@ -196,7 +196,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);
|
||||
@@ -212,7 +212,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
|
||||
}
|
||||
}
|
||||
|
||||
return (anns.isEmpty() ? null : anns);
|
||||
return (!anns.isEmpty() ? anns : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user