Skip to content

Commit 1ee0626

Browse files
committed
Polishing
1 parent 74bdcd8 commit 1ee0626

File tree

6 files changed

+26
-28
lines changed

6 files changed

+26
-28
lines changed

spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,14 +47,12 @@
4747
* at the type level of the containing target class, applying to all public service methods
4848
* of that class. By default, JSR-303 will validate against its default group only.
4949
*
50-
* <p>As of Spring 5.0, this functionality requires a Bean Validation 1.1 provider
51-
* (such as Hibernate Validator 5.x).
50+
* <p>As of Spring 5.0, this functionality requires a Bean Validation 1.1 provider.
5251
*
5352
* @author Juergen Hoeller
5453
* @since 3.1
5554
* @see MethodValidationPostProcessor
5655
* @see javax.validation.executable.ExecutableValidator
57-
* @see org.hibernate.validator.method.MethodValidator
5856
*/
5957
public class MethodValidationInterceptor implements MethodInterceptor {
6058

spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,14 +48,12 @@
4848
* inline constraint annotations. Validation groups can be specified through {@code @Validated}
4949
* as well. By default, JSR-303 will validate against its default group only.
5050
*
51-
* <p>As of Spring 4.0, this functionality requires either a Bean Validation 1.1 provider
52-
* (such as Hibernate Validator 5.x) or the Bean Validation 1.0 API with Hibernate Validator
53-
* 4.3. The actual provider will be autodetected and automatically adapted.
51+
* <p>As of Spring 5.0, this functionality requires a Bean Validation 1.1 provider.
5452
*
5553
* @author Juergen Hoeller
5654
* @since 3.1
5755
* @see MethodValidationInterceptor
58-
* @see org.hibernate.validator.method.MethodValidator
56+
* @see javax.validation.executable.ExecutableValidator
5957
*/
6058
@SuppressWarnings("serial")
6159
public class MethodValidationPostProcessor extends AbstractBeanFactoryAwareAdvisingPostProcessor

spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,8 +54,7 @@
5454
* @author Rossen Stoyanchev
5555
* @since 3.1
5656
*/
57-
public class ModelAttributeMethodProcessor
58-
implements HandlerMethodArgumentResolver, HandlerMethodReturnValueHandler {
57+
public class ModelAttributeMethodProcessor implements HandlerMethodArgumentResolver, HandlerMethodReturnValueHandler {
5958

6059
protected final Log logger = LogFactory.getLog(getClass());
6160

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -250,7 +250,7 @@ protected ServletServerHttpRequest createInputMessage(NativeWebRequest webReques
250250
}
251251

252252
/**
253-
* Validate the request part if applicable.
253+
* Validate the binding target if applicable.
254254
* <p>The default implementation checks for {@code @javax.validation.Valid},
255255
* Spring's {@link org.springframework.validation.annotation.Validated},
256256
* and custom annotations whose name starts with "Valid".

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -110,8 +110,8 @@ public void setHandlerMethodReturnValueHandlers(HandlerMethodReturnValueHandlerC
110110
* @param mavContainer the ModelAndViewContainer for this request
111111
* @param providedArgs "given" arguments matched by type (not resolved)
112112
*/
113-
public void invokeAndHandle(ServletWebRequest webRequest,
114-
ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception {
113+
public void invokeAndHandle(ServletWebRequest webRequest, ModelAndViewContainer mavContainer,
114+
Object... providedArgs) throws Exception {
115115

116116
Object returnValue = invokeForRequest(webRequest, mavContainer, providedArgs);
117117
setResponseStatus(webRequest);

spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -142,7 +142,6 @@
142142
import org.springframework.web.servlet.view.tiles3.TilesViewResolver;
143143
import org.springframework.web.util.UrlPathHelper;
144144

145-
import static org.hamcrest.CoreMatchers.instanceOf;
146145
import static org.hamcrest.Matchers.*;
147146
import static org.junit.Assert.*;
148147

@@ -159,7 +158,9 @@
159158
*/
160159
public class MvcNamespaceTests {
161160

162-
public static final String VIEWCONTROLLER_BEAN_NAME = "org.springframework.web.servlet.config.viewControllerHandlerMapping";
161+
public static final String VIEWCONTROLLER_BEAN_NAME =
162+
"org.springframework.web.servlet.config.viewControllerHandlerMapping";
163+
163164

164165
private GenericWebApplicationContext appContext;
165166

@@ -197,7 +198,7 @@ public void testDefaultConfig() throws Exception {
197198
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo.json");
198199
NativeWebRequest webRequest = new ServletWebRequest(request);
199200
ContentNegotiationManager manager = mapping.getContentNegotiationManager();
200-
assertEquals(Arrays.asList(MediaType.APPLICATION_JSON), manager.resolveMediaTypes(webRequest));
201+
assertEquals(Collections.singletonList(MediaType.APPLICATION_JSON), manager.resolveMediaTypes(webRequest));
201202

202203
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
203204
assertNotNull(adapter);
@@ -697,7 +698,8 @@ public void testContentNegotiationManager() throws Exception {
697698

698699
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo.xml");
699700
NativeWebRequest webRequest = new ServletWebRequest(request);
700-
assertEquals(Arrays.asList(MediaType.valueOf("application/rss+xml")), manager.resolveMediaTypes(webRequest));
701+
assertEquals(Collections.singletonList(MediaType.valueOf("application/rss+xml")),
702+
manager.resolveMediaTypes(webRequest));
701703

702704
ViewResolverComposite compositeResolver = this.appContext.getBean(ViewResolverComposite.class);
703705
assertNotNull(compositeResolver);
@@ -882,7 +884,7 @@ public void testCorsMinimal() throws Exception {
882884
assertArrayEquals(new String[]{"*"}, config.getAllowedHeaders().toArray());
883885
assertNull(config.getExposedHeaders());
884886
assertTrue(config.getAllowCredentials());
885-
assertEquals(new Long(1800), config.getMaxAge());
887+
assertEquals(Long.valueOf(1800), config.getMaxAge());
886888
}
887889
}
888890

@@ -905,14 +907,14 @@ public void testCors() throws Exception {
905907
assertArrayEquals(new String[]{"header1", "header2", "header3"}, config.getAllowedHeaders().toArray());
906908
assertArrayEquals(new String[]{"header1", "header2"}, config.getExposedHeaders().toArray());
907909
assertFalse(config.getAllowCredentials());
908-
assertEquals(new Long(123), config.getMaxAge());
910+
assertEquals(Long.valueOf(123), config.getMaxAge());
909911
config = configs.get("/resources/**");
910912
assertArrayEquals(new String[]{"http://domain1.com"}, config.getAllowedOrigins().toArray());
911913
assertArrayEquals(new String[]{"GET", "HEAD", "POST"}, config.getAllowedMethods().toArray());
912914
assertArrayEquals(new String[]{"*"}, config.getAllowedHeaders().toArray());
913915
assertNull(config.getExposedHeaders());
914916
assertTrue(config.getAllowCredentials());
915-
assertEquals(new Long(1800), config.getMaxAge());
917+
assertEquals(Long.valueOf(1800), config.getMaxAge());
916918
}
917919
}
918920

@@ -928,21 +930,21 @@ private void loadBeanDefinitions(String fileName, int expectedBeanCount) {
928930

929931

930932
@DateTimeFormat(iso = ISO.DATE)
931-
@Target({ElementType.PARAMETER})
933+
@Target(ElementType.PARAMETER)
932934
@Retention(RetentionPolicy.RUNTIME)
933935
public @interface IsoDate {
934936
}
935937

936938

937939
@NumberFormat(style = NumberFormat.Style.PERCENT)
938-
@Target({ElementType.PARAMETER})
940+
@Target(ElementType.PARAMETER)
939941
@Retention(RetentionPolicy.RUNTIME)
940942
public @interface PercentNumber {
941943
}
942944

943945

944946
@Validated(MyGroup.class)
945-
@Target({ElementType.PARAMETER})
947+
@Target(ElementType.PARAMETER)
946948
@Retention(RetentionPolicy.RUNTIME)
947949
public @interface MyValid {
948950
}
@@ -961,6 +963,7 @@ public static class TestController {
961963
public void testBind(@RequestParam @IsoDate Date date,
962964
@RequestParam(required = false) @PercentNumber Double percent,
963965
@MyValid TestBean bean, BindingResult result) {
966+
964967
this.date = date;
965968
this.percent = percent;
966969
this.recordedValidationError = (result.getErrorCount() == 1);

0 commit comments

Comments
 (0)