Polishing
This commit is contained in:
@@ -769,8 +769,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
if (this.parentBeanFactory != null && this.parentBeanFactory != parentBeanFactory) {
|
||||
throw new IllegalStateException("Already associated with parent BeanFactory: " + this.parentBeanFactory);
|
||||
}
|
||||
if(this == parentBeanFactory) {
|
||||
throw new IllegalStateException("Can not set parent bean factory to self.");
|
||||
if (this == parentBeanFactory) {
|
||||
throw new IllegalStateException("Cannot set parent bean factory to self");
|
||||
}
|
||||
this.parentBeanFactory = parentBeanFactory;
|
||||
}
|
||||
|
||||
@@ -73,18 +73,19 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
|
||||
private static final Map<Class<?>, Object> EMPTY_ARRAYS;
|
||||
static {
|
||||
Map<Class<?>, Object> emptyArrays = new HashMap<>();
|
||||
emptyArrays.put(String.class, new String[] {});
|
||||
emptyArrays.put(boolean.class, new boolean[] {});
|
||||
emptyArrays.put(byte.class, new byte[] {});
|
||||
emptyArrays.put(char.class, new char[] {});
|
||||
emptyArrays.put(double.class, new double[] {});
|
||||
emptyArrays.put(float.class, new float[] {});
|
||||
emptyArrays.put(int.class, new int[] {});
|
||||
emptyArrays.put(long.class, new long[] {});
|
||||
emptyArrays.put(short.class, new short[] {});
|
||||
emptyArrays.put(boolean.class, new boolean[0]);
|
||||
emptyArrays.put(byte.class, new byte[0]);
|
||||
emptyArrays.put(char.class, new char[0]);
|
||||
emptyArrays.put(double.class, new double[0]);
|
||||
emptyArrays.put(float.class, new float[0]);
|
||||
emptyArrays.put(int.class, new int[0]);
|
||||
emptyArrays.put(long.class, new long[0]);
|
||||
emptyArrays.put(short.class, new short[0]);
|
||||
emptyArrays.put(String.class, new String[0]);
|
||||
EMPTY_ARRAYS = Collections.unmodifiableMap(emptyArrays);
|
||||
}
|
||||
|
||||
|
||||
private final AnnotationTypeMapping mapping;
|
||||
|
||||
@Nullable
|
||||
@@ -427,9 +428,8 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
|
||||
}
|
||||
}
|
||||
if (!forMirrorResolution) {
|
||||
attributeIndex = (mapping.getDistance() != 0 ?
|
||||
this.resolvedMirrors :
|
||||
this.resolvedRootMirrors)[attributeIndex];
|
||||
attributeIndex =
|
||||
(mapping.getDistance() != 0 ? this.resolvedMirrors : this.resolvedRootMirrors)[attributeIndex];
|
||||
}
|
||||
if (attributeIndex == -1) {
|
||||
return null;
|
||||
@@ -437,15 +437,13 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
|
||||
if (mapping.getDistance() == 0) {
|
||||
Method attribute = mapping.getAttributes().get(attributeIndex);
|
||||
Object result = this.valueExtractor.extract(attribute, this.rootAttributes);
|
||||
return (result != null) ? result : attribute.getDefaultValue();
|
||||
return (result != null ? result : attribute.getDefaultValue());
|
||||
}
|
||||
return getValueFromMetaAnnotation(attributeIndex, forMirrorResolution);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object getValueFromMetaAnnotation(int attributeIndex,
|
||||
boolean forMirrorResolution) {
|
||||
|
||||
private Object getValueFromMetaAnnotation(int attributeIndex, boolean forMirrorResolution) {
|
||||
Object value = null;
|
||||
if (this.useMergedValues || forMirrorResolution) {
|
||||
value = this.mapping.getMappedAnnotationValue(attributeIndex, forMirrorResolution);
|
||||
@@ -479,7 +477,7 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
|
||||
value = ClassUtils.resolveClassName((String) value, getClassLoader());
|
||||
}
|
||||
else if (value instanceof Class[] && type == String[].class) {
|
||||
Class<?>[] classes = (Class[]) value;
|
||||
Class<?>[] classes = (Class<?>[]) value;
|
||||
String[] names = new String[classes.length];
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
names[i] = classes[i].getName();
|
||||
@@ -522,10 +520,9 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
|
||||
return adaptForAttribute(attribute, array);
|
||||
}
|
||||
if (attributeType.isAnnotation()) {
|
||||
return adaptToMergedAnnotation(value,(Class<? extends Annotation>) attributeType);
|
||||
return adaptToMergedAnnotation(value, (Class<? extends Annotation>) attributeType);
|
||||
}
|
||||
if (attributeType.isArray() && attributeType.getComponentType().isAnnotation() &&
|
||||
value.getClass().isArray()) {
|
||||
if (attributeType.isArray() && attributeType.getComponentType().isAnnotation()) {
|
||||
MergedAnnotation<?>[] result = new MergedAnnotation<?>[Array.getLength(value)];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = adaptToMergedAnnotation(Array.get(value, i),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -151,6 +151,7 @@ public class ModelAttributeMethodArgumentResolver extends HandlerMethodArgumentR
|
||||
* Extension point to bind the request to the target object.
|
||||
* @param binder the data binder instance to use for the binding
|
||||
* @param exchange the current request
|
||||
* @since 5.2.6
|
||||
*/
|
||||
protected Mono<Void> bindRequestParameters(WebExchangeDataBinder binder, ServerWebExchange exchange) {
|
||||
return binder.bind(exchange);
|
||||
|
||||
Reference in New Issue
Block a user