mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-02 00:10:58 +08:00
fix code
This commit is contained in:
parent
8a9cce4f55
commit
9cd0313935
@ -90,7 +90,7 @@ public final class AnnotationMappingProxy<T extends Annotation> implements Invoc
|
|||||||
* @param annotation 属性映射
|
* @param annotation 属性映射
|
||||||
*/
|
*/
|
||||||
private AnnotationMappingProxy(final AnnotationMapping<T> annotation) {
|
private AnnotationMappingProxy(final AnnotationMapping<T> annotation) {
|
||||||
int methodCount = annotation.getAttributes().length;
|
final int methodCount = annotation.getAttributes().length;
|
||||||
this.methods = new HashMap<>(methodCount + 5);
|
this.methods = new HashMap<>(methodCount + 5);
|
||||||
this.valueCache = new SafeConcurrentHashMap<>(methodCount);
|
this.valueCache = new SafeConcurrentHashMap<>(methodCount);
|
||||||
this.mapping = annotation;
|
this.mapping = annotation;
|
||||||
@ -123,7 +123,7 @@ public final class AnnotationMappingProxy<T extends Annotation> implements Invoc
|
|||||||
methods.put("hashCode", (method, args) -> proxyHashCode());
|
methods.put("hashCode", (method, args) -> proxyHashCode());
|
||||||
methods.put("annotationType", (method, args) -> proxyAnnotationType());
|
methods.put("annotationType", (method, args) -> proxyAnnotationType());
|
||||||
methods.put("getMapping", (method, args) -> proxyGetMapping());
|
methods.put("getMapping", (method, args) -> proxyGetMapping());
|
||||||
for (Method attribute : mapping.getAttributes()) {
|
for (final Method attribute : mapping.getAttributes()) {
|
||||||
methods.put(attribute.getName(), (method, args) -> getAttributeValue(method.getName(), method.getReturnType()));
|
methods.put(attribute.getName(), (method, args) -> getAttributeValue(method.getName(), method.getReturnType()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ public final class AnnotationMappingProxy<T extends Annotation> implements Invoc
|
|||||||
/**
|
/**
|
||||||
* 代理{@link Annotation#equals(Object)}方法
|
* 代理{@link Annotation#equals(Object)}方法
|
||||||
*/
|
*/
|
||||||
private boolean proxyEquals(Object o) {
|
private boolean proxyEquals(final Object o) {
|
||||||
return Objects.equals(mapping, o);
|
return Objects.equals(mapping, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ import java.util.function.BiFunction;
|
|||||||
* @author huangchengxing
|
* @author huangchengxing
|
||||||
* @see ResolvedAnnotationMapping
|
* @see ResolvedAnnotationMapping
|
||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
|
* @param <T> AnnotationMapping类型
|
||||||
*/
|
*/
|
||||||
public class MetaAnnotatedElement<T extends AnnotationMapping<Annotation>> implements AnnotatedElement, Iterable<T> {
|
public class MetaAnnotatedElement<T extends AnnotationMapping<Annotation>> implements AnnotatedElement, Iterable<T> {
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ public class MetaAnnotatedElement<T extends AnnotationMapping<Annotation>> imple
|
|||||||
* @return 是否
|
* @return 是否
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
|
public boolean isAnnotationPresent(final Class<? extends Annotation> annotationType) {
|
||||||
return getMapping(annotationType)
|
return getMapping(annotationType)
|
||||||
.isPresent();
|
.isPresent();
|
||||||
}
|
}
|
||||||
@ -299,7 +300,7 @@ public class MetaAnnotatedElement<T extends AnnotationMapping<Annotation>> imple
|
|||||||
if (Objects.isNull(annotationMappings)) {
|
if (Objects.isNull(annotationMappings)) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (Objects.isNull(annotationMappings)) {
|
if (Objects.isNull(annotationMappings)) {
|
||||||
Map<Class<? extends Annotation>, T> mappings = new LinkedHashMap<>(8);
|
final Map<Class<? extends Annotation>, T> mappings = new LinkedHashMap<>(8);
|
||||||
initAnnotationMappings(mappings);
|
initAnnotationMappings(mappings);
|
||||||
this.annotationMappings = Collections.unmodifiableMap(mappings);
|
this.annotationMappings = Collections.unmodifiableMap(mappings);
|
||||||
}
|
}
|
||||||
@ -319,7 +320,7 @@ public class MetaAnnotatedElement<T extends AnnotationMapping<Annotation>> imple
|
|||||||
.forEach(deque::addLast);
|
.forEach(deque::addLast);
|
||||||
while (!deque.isEmpty()) {
|
while (!deque.isEmpty()) {
|
||||||
// 若已有该类型的注解,则不再进行扫描
|
// 若已有该类型的注解,则不再进行扫描
|
||||||
T mapping = deque.removeFirst();
|
final T mapping = deque.removeFirst();
|
||||||
if (!isNeedMapping(mappings, mapping)) {
|
if (!isNeedMapping(mappings, mapping)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ import java.util.stream.Collectors;
|
|||||||
* @author huangchengxing
|
* @author huangchengxing
|
||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
* @see RepeatableAnnotationCollector
|
* @see RepeatableAnnotationCollector
|
||||||
|
* @param <T> AnnotationMapping类型
|
||||||
*/
|
*/
|
||||||
public class RepeatableMetaAnnotatedElement<T extends AnnotationMapping<Annotation>> implements AnnotatedElement, Iterable<T> {
|
public class RepeatableMetaAnnotatedElement<T extends AnnotationMapping<Annotation>> implements AnnotatedElement, Iterable<T> {
|
||||||
|
|
||||||
@ -282,9 +283,9 @@ public class RepeatableMetaAnnotatedElement<T extends AnnotationMapping<Annotati
|
|||||||
*/
|
*/
|
||||||
private List<Aggregation> initAggregations(final AnnotatedElement element) {
|
private List<Aggregation> initAggregations(final AnnotatedElement element) {
|
||||||
// TODO 若有可能,一并支持处理元注解中的可重复注解
|
// TODO 若有可能,一并支持处理元注解中的可重复注解
|
||||||
List<Aggregation> result = new ArrayList<>();
|
final List<Aggregation> result = new ArrayList<>();
|
||||||
for (final Annotation declaredAnnotation : AnnotationUtil.getDeclaredAnnotations(element)) {
|
for (final Annotation declaredAnnotation : AnnotationUtil.getDeclaredAnnotations(element)) {
|
||||||
List<Aggregation> repeatableAnnotations = collectRepeatable(declaredAnnotation);
|
final List<Aggregation> repeatableAnnotations = collectRepeatable(declaredAnnotation);
|
||||||
if (CollUtil.isNotEmpty(repeatableAnnotations)) {
|
if (CollUtil.isNotEmpty(repeatableAnnotations)) {
|
||||||
result.addAll(repeatableAnnotations);
|
result.addAll(repeatableAnnotations);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user