This commit is contained in:
huangchengxing 2022-06-30 15:38:11 +08:00
parent 8cf3015075
commit 10f3abfeb8
5 changed files with 9 additions and 9 deletions

View File

@ -256,7 +256,7 @@ public abstract class AbstractTypeAnnotationScanner<T extends AbstractTypeAnnota
*/ */
protected Class<?> convert(Class<?> target) { protected Class<?> convert(Class<?> target) {
if (hasConverters) { if (hasConverters) {
for (UnaryOperator<Class<?>> converter : converters) { for (final UnaryOperator<Class<?>> converter : converters) {
target = converter.apply(target); target = converter.apply(target);
} }
} }

View File

@ -70,7 +70,7 @@ public interface AnnotationScanner {
*/ */
default void scan(BiConsumer<Integer, Annotation> consumer, AnnotatedElement annotatedEle, Predicate<Annotation> filter) { default void scan(BiConsumer<Integer, Annotation> consumer, AnnotatedElement annotatedEle, Predicate<Annotation> filter) {
filter = ObjectUtil.defaultIfNull(filter, annotation -> true); filter = ObjectUtil.defaultIfNull(filter, annotation -> true);
for (Annotation annotation : annotatedEle.getAnnotations()) { for (final Annotation annotation : annotatedEle.getAnnotations()) {
if (AnnotationUtil.isNotJdkMateAnnotation(annotation.annotationType()) && filter.test(annotation)) { if (AnnotationUtil.isNotJdkMateAnnotation(annotation.annotationType()) && filter.test(annotation)) {
consumer.accept(0, annotation); consumer.accept(0, annotation);
} }

View File

@ -37,7 +37,7 @@ public class FieldAnnotationScanner implements AnnotationScanner {
@Override @Override
public void scan(BiConsumer<Integer, Annotation> consumer, AnnotatedElement annotatedEle, Predicate<Annotation> filter) { public void scan(BiConsumer<Integer, Annotation> consumer, AnnotatedElement annotatedEle, Predicate<Annotation> filter) {
filter = ObjectUtil.defaultIfNull(filter, annotation -> true); filter = ObjectUtil.defaultIfNull(filter, annotation -> true);
for (Annotation annotation : annotatedEle.getAnnotations()) { for (final Annotation annotation : annotatedEle.getAnnotations()) {
if (AnnotationUtil.isNotJdkMateAnnotation(annotation.annotationType()) && filter.test(annotation)) { if (AnnotationUtil.isNotJdkMateAnnotation(annotation.annotationType()) && filter.test(annotation)) {
consumer.accept(0, annotation); consumer.accept(0, annotation);
} }

View File

@ -79,7 +79,7 @@ public class MethodAnnotationScanner extends AbstractTypeAnnotationScanner<Metho
*/ */
@Override @Override
protected Annotation[] getAnnotationsFromTargetClass(AnnotatedElement source, int index, Class<?> targetClass) { protected Annotation[] getAnnotationsFromTargetClass(AnnotatedElement source, int index, Class<?> targetClass) {
Method sourceMethod = (Method) source; final Method sourceMethod = (Method) source;
return Stream.of(targetClass.getDeclaredMethods()) return Stream.of(targetClass.getDeclaredMethods())
.filter(superMethod -> !superMethod.isBridge()) .filter(superMethod -> !superMethod.isBridge())
.filter(superMethod -> hasSameSignature(sourceMethod, superMethod)) .filter(superMethod -> hasSameSignature(sourceMethod, superMethod))
@ -104,11 +104,11 @@ public class MethodAnnotationScanner extends AbstractTypeAnnotationScanner<Metho
* 该方法是否具备与扫描的方法相同的方法签名 * 该方法是否具备与扫描的方法相同的方法签名
*/ */
private boolean hasSameSignature(Method sourceMethod, Method superMethod) { private boolean hasSameSignature(Method sourceMethod, Method superMethod) {
if (!StrUtil.equals(sourceMethod.getName(), superMethod.getName())) { if (false == StrUtil.equals(sourceMethod.getName(), superMethod.getName())) {
return false; return false;
} }
Class<?>[] sourceParameterTypes = sourceMethod.getParameterTypes(); final Class<?>[] sourceParameterTypes = sourceMethod.getParameterTypes();
Class<?>[] targetParameterTypes = superMethod.getParameterTypes(); final Class<?>[] targetParameterTypes = superMethod.getParameterTypes();
if (sourceParameterTypes.length != targetParameterTypes.length) { if (sourceParameterTypes.length != targetParameterTypes.length) {
return false; return false;
} }