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) {
if (hasConverters) {
for (UnaryOperator<Class<?>> converter : converters) {
for (final UnaryOperator<Class<?>> converter : converters) {
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) {
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)) {
consumer.accept(0, annotation);
}

View File

@ -37,7 +37,7 @@ public class FieldAnnotationScanner implements AnnotationScanner {
@Override
public void scan(BiConsumer<Integer, Annotation> consumer, AnnotatedElement annotatedEle, Predicate<Annotation> filter) {
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)) {
consumer.accept(0, annotation);
}

View File

@ -67,8 +67,8 @@ public class MetaAnnotationScanner implements AnnotationScanner {
public List<Annotation> getAnnotations(AnnotatedElement annotatedEle) {
final List<Annotation> annotations = new ArrayList<>();
scan(
(index, annotation) -> annotations.add(annotation), annotatedEle,
annotation -> ObjectUtil.notEqual(annotation, annotatedEle)
(index, annotation) -> annotations.add(annotation), annotatedEle,
annotation -> ObjectUtil.notEqual(annotation, annotatedEle)
);
return annotations;
}

View File

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