mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-21 13:31:46 +00:00
Polishing (aligned with main)
This commit is contained in:
+14
-16
@@ -377,47 +377,45 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
|
||||
protected void postProcessConfiguration(Configuration<?> configuration) {
|
||||
}
|
||||
|
||||
private ValidatorFactory obtainValidatorFactory() {
|
||||
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
|
||||
return this.validatorFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Validator getValidator() {
|
||||
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
|
||||
return this.validatorFactory.getValidator();
|
||||
return obtainValidatorFactory().getValidator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValidatorContext usingContext() {
|
||||
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
|
||||
return this.validatorFactory.usingContext();
|
||||
return obtainValidatorFactory().usingContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageInterpolator getMessageInterpolator() {
|
||||
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
|
||||
return this.validatorFactory.getMessageInterpolator();
|
||||
return obtainValidatorFactory().getMessageInterpolator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraversableResolver getTraversableResolver() {
|
||||
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
|
||||
return this.validatorFactory.getTraversableResolver();
|
||||
return obtainValidatorFactory().getTraversableResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstraintValidatorFactory getConstraintValidatorFactory() {
|
||||
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
|
||||
return this.validatorFactory.getConstraintValidatorFactory();
|
||||
return obtainValidatorFactory().getConstraintValidatorFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParameterNameProvider getParameterNameProvider() {
|
||||
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
|
||||
return this.validatorFactory.getParameterNameProvider();
|
||||
return obtainValidatorFactory().getParameterNameProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClockProvider getClockProvider() {
|
||||
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
|
||||
return this.validatorFactory.getClockProvider();
|
||||
return obtainValidatorFactory().getClockProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -427,8 +425,8 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
|
||||
try {
|
||||
return super.unwrap(type);
|
||||
}
|
||||
catch (ValidationException ex) {
|
||||
// Ignore - we'll try ValidatorFactory unwrapping next
|
||||
catch (ValidationException ignored) {
|
||||
// Trying ValidatorFactory unwrapping next
|
||||
}
|
||||
}
|
||||
if (this.validatorFactory != null) {
|
||||
|
||||
+3
-1
@@ -26,7 +26,7 @@ import org.springframework.context.support.MessageSourceResourceBundle;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Implementation of Hibernate Validator 4.3/5.x's {@link ResourceBundleLocator} interface,
|
||||
* Implementation of Hibernate Validator's {@link ResourceBundleLocator} interface,
|
||||
* exposing a Spring {@link MessageSource} as localized {@link MessageSourceResourceBundle}.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
@@ -39,6 +39,7 @@ public class MessageSourceResourceBundleLocator implements ResourceBundleLocator
|
||||
|
||||
private final MessageSource messageSource;
|
||||
|
||||
|
||||
/**
|
||||
* Build a MessageSourceResourceBundleLocator for the given MessageSource.
|
||||
* @param messageSource the Spring MessageSource to wrap
|
||||
@@ -48,6 +49,7 @@ public class MessageSourceResourceBundleLocator implements ResourceBundleLocator
|
||||
this.messageSource = messageSource;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceBundle getResourceBundle(Locale locale) {
|
||||
return new MessageSourceResourceBundle(this.messageSource, locale);
|
||||
|
||||
Reference in New Issue
Block a user