mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish
This commit is contained in:
parent
c46bef1858
commit
f3f8610539
@ -2,19 +2,15 @@
|
||||
<hazelcast-client xmlns="http://www.hazelcast.com/schema/client-config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-5.0.xsd">
|
||||
|
||||
<instance-name>spring-boot</instance-name>
|
||||
|
||||
<connection-strategy>
|
||||
<connection-retry>
|
||||
<cluster-connect-timeout-millis>60000</cluster-connect-timeout-millis>
|
||||
</connection-retry>
|
||||
</connection-strategy>
|
||||
|
||||
<network>
|
||||
<cluster-members>
|
||||
<address>${address}</address>
|
||||
</cluster-members>
|
||||
</network>
|
||||
|
||||
</hazelcast-client>
|
||||
|
@ -137,7 +137,6 @@ class ConfigurationPropertiesBinder {
|
||||
: new IgnoreTopLevelConverterNotFoundBindHandler();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Validator> getValidators(Bindable<?> target) {
|
||||
List<Validator> validators = new ArrayList<>(3);
|
||||
if (this.configurationPropertiesValidator != null) {
|
||||
@ -146,17 +145,25 @@ class ConfigurationPropertiesBinder {
|
||||
if (this.jsr303Present && target.getAnnotation(Validated.class) != null) {
|
||||
validators.add(getJsr303Validator());
|
||||
}
|
||||
if (target.getValue() != null) {
|
||||
if (target.getValue().get() instanceof Validator) {
|
||||
validators.add((Validator) target.getValue().get());
|
||||
}
|
||||
}
|
||||
else if (Validator.class.isAssignableFrom(target.getType().resolve())) {
|
||||
validators.add(new SelfValidatingConstructorBoundBindableValidator((Bindable<? extends Validator>) target));
|
||||
Validator selfValidator = getSelfValidator(target);
|
||||
if (selfValidator != null) {
|
||||
validators.add(selfValidator);
|
||||
}
|
||||
return validators;
|
||||
}
|
||||
|
||||
private Validator getSelfValidator(Bindable<?> target) {
|
||||
if (target.getValue() != null) {
|
||||
Object value = target.getValue().get();
|
||||
return (value instanceof Validator) ? (Validator) value : null;
|
||||
}
|
||||
Class<?> type = target.getType().resolve();
|
||||
if (Validator.class.isAssignableFrom(type)) {
|
||||
return new SelfValidatingConstructorBoundBindableValidator(type);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Validator getJsr303Validator() {
|
||||
if (this.jsr303Validator == null) {
|
||||
this.jsr303Validator = new ConfigurationPropertiesJsr303Validator(this.applicationContext);
|
||||
@ -271,15 +278,15 @@ class ConfigurationPropertiesBinder {
|
||||
*/
|
||||
static class SelfValidatingConstructorBoundBindableValidator implements Validator {
|
||||
|
||||
private final Bindable<? extends Validator> bindable;
|
||||
private final Class<?> type;
|
||||
|
||||
SelfValidatingConstructorBoundBindableValidator(Bindable<? extends Validator> bindable) {
|
||||
this.bindable = bindable;
|
||||
SelfValidatingConstructorBoundBindableValidator(Class<?> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return clazz.isAssignableFrom(this.bindable.getType().resolve());
|
||||
public boolean supports(Class<?> candidate) {
|
||||
return candidate.isAssignableFrom(this.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user