mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code
This commit is contained in:
parent
8cf3015075
commit
10f3abfeb8
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,8 @@ public class MetaAnnotationScanner implements AnnotationScanner {
|
|||||||
public List<Annotation> getAnnotations(AnnotatedElement annotatedEle) {
|
public List<Annotation> getAnnotations(AnnotatedElement annotatedEle) {
|
||||||
final List<Annotation> annotations = new ArrayList<>();
|
final List<Annotation> annotations = new ArrayList<>();
|
||||||
scan(
|
scan(
|
||||||
(index, annotation) -> annotations.add(annotation), annotatedEle,
|
(index, annotation) -> annotations.add(annotation), annotatedEle,
|
||||||
annotation -> ObjectUtil.notEqual(annotation, annotatedEle)
|
annotation -> ObjectUtil.notEqual(annotation, annotatedEle)
|
||||||
);
|
);
|
||||||
return annotations;
|
return annotations;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user