mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +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);
|
||||
|
||||
+1
-3
@@ -93,7 +93,7 @@ public abstract class AbstractGenericHttpMessageConverter<T> extends AbstractHtt
|
||||
* and then calls {@link #writeInternal}.
|
||||
*/
|
||||
@Override
|
||||
public final void write(final T t, @Nullable final Type type, @Nullable MediaType contentType,
|
||||
public final void write(final T t, final @Nullable Type type, @Nullable MediaType contentType,
|
||||
HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
|
||||
|
||||
final HttpHeaders headers = outputMessage.getHeaders();
|
||||
@@ -108,14 +108,12 @@ public abstract class AbstractGenericHttpMessageConverter<T> extends AbstractHtt
|
||||
public OutputStream getBody() {
|
||||
return outputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean repeatable() {
|
||||
return supportsRepeatableWrites(t);
|
||||
|
||||
-1
@@ -224,7 +224,6 @@ public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConv
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean repeatable() {
|
||||
return supportsRepeatableWrites(t);
|
||||
|
||||
-1
@@ -106,7 +106,6 @@ public abstract class AbstractSmartHttpMessageConverter<T> extends AbstractHttpM
|
||||
}
|
||||
}, hints);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean repeatable() {
|
||||
return supportsRepeatableWrites(t);
|
||||
|
||||
+1
-2
@@ -218,7 +218,7 @@ public class BufferedImageHttpMessageConverter implements HttpMessageConverter<B
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final BufferedImage image, @Nullable final MediaType contentType,
|
||||
public void write(final BufferedImage image, final @Nullable MediaType contentType,
|
||||
final HttpOutputMessage outputMessage)
|
||||
throws IOException, HttpMessageNotWritableException {
|
||||
|
||||
@@ -231,7 +231,6 @@ public class BufferedImageHttpMessageConverter implements HttpMessageConverter<B
|
||||
public void writeTo(OutputStream outputStream) throws IOException {
|
||||
BufferedImageHttpMessageConverter.this.writeInternal(image, selectedContentType, outputStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean repeatable() {
|
||||
return true;
|
||||
|
||||
-1
@@ -414,7 +414,6 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
public void writeTo(OutputStream outputStream) throws IOException {
|
||||
StreamUtils.copy(bytes, outputStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean repeatable() {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user