Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2eb830d

Browse files
committedMay 12, 2017
DATACMNS-822 - Polishing.
Switched to implement WebMvcConfigurer over extending WebMvcConfigurerAdapter. Formatting, assertions, Javadoc. Original pull request: #208.
1 parent 364ed9a commit 2eb830d

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed
 

‎src/main/java/org/springframework/data/web/config/HateoasAwareSpringDataWebConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public HateoasAwareSpringDataWebConfiguration(ApplicationContext context,
5858
@Override
5959
public HateoasPageableHandlerMethodArgumentResolver pageableResolver() {
6060

61-
HateoasPageableHandlerMethodArgumentResolver pageableResolver = //
62-
new HateoasPageableHandlerMethodArgumentResolver(sortResolver());
61+
HateoasPageableHandlerMethodArgumentResolver pageableResolver = new HateoasPageableHandlerMethodArgumentResolver(
62+
sortResolver());
6363
customizePageableResolver(pageableResolver);
6464
return pageableResolver;
6565
}

‎src/main/java/org/springframework/data/web/config/PageableHandlerMethodArgumentResolverCustomizer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@
2222
* {@link PageableHandlerMethodArgumentResolver} configuration.
2323
*
2424
* @author Vedran Pavic
25+
* @author Oliver Gierke
26+
* @since 2.0
2527
*/
28+
@FunctionalInterface
2629
public interface PageableHandlerMethodArgumentResolverCustomizer {
2730

2831
/**
29-
* Customize the pageable resolver
32+
* Customize the given {@link PageableHandlerMethodArgumentResolver}.
3033
*
31-
* @param pageableResolver the {@link PageableHandlerMethodArgumentResolver} to customize
34+
* @param pageableResolver the {@link PageableHandlerMethodArgumentResolver} to customize, will never be
35+
* {@literal null}.
3236
*/
3337
void customize(PageableHandlerMethodArgumentResolver pageableResolver);
34-
3538
}

‎src/main/java/org/springframework/data/web/config/QuerydslWebConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.springframework.data.querydsl.binding.QuerydslBindingsFactory;
3030
import org.springframework.data.web.querydsl.QuerydslPredicateArgumentResolver;
3131
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
32-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
32+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
3333

3434
import com.querydsl.core.types.Predicate;
3535

@@ -42,7 +42,7 @@
4242
* @soundtrack Anika Nilles - Alter Ego
4343
*/
4444
@Configuration
45-
public class QuerydslWebConfiguration extends WebMvcConfigurerAdapter {
45+
public class QuerydslWebConfiguration implements WebMvcConfigurer {
4646

4747
@Autowired @Qualifier("mvcConversionService") ObjectFactory<ConversionService> conversionService;
4848

‎src/main/java/org/springframework/data/web/config/SortHandlerMethodArgumentResolverCustomizer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222
* {@link SortHandlerMethodArgumentResolver} configuration.
2323
*
2424
* @author Vedran Pavic
25+
* @author Oliver Gierke
26+
* @since 2.0
2527
*/
2628
public interface SortHandlerMethodArgumentResolverCustomizer {
2729

2830
/**
29-
* Customize the sort resolver
31+
* Customize the given {@link SortHandlerMethodArgumentResolver}.
3032
*
31-
* @param sortResolver the {@link SortHandlerMethodArgumentResolver} to customize
33+
* @param sortResolver the {@link SortHandlerMethodArgumentResolver} to customize, will never be {@literal null}.
3234
*/
3335
void customize(SortHandlerMethodArgumentResolver sortResolver);
34-
3536
}

‎src/main/java/org/springframework/data/web/config/SpringDataWebConfiguration.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@
3636
import org.springframework.format.FormatterRegistry;
3737
import org.springframework.format.support.FormattingConversionService;
3838
import org.springframework.http.converter.HttpMessageConverter;
39+
import org.springframework.util.Assert;
3940
import org.springframework.util.ClassUtils;
4041
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
41-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
42+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
4243

4344
import com.fasterxml.jackson.databind.ObjectMapper;
4445

@@ -52,18 +53,19 @@
5253
* @author Jens Schauder
5354
*/
5455
@Configuration
55-
public class SpringDataWebConfiguration extends WebMvcConfigurerAdapter {
56+
public class SpringDataWebConfiguration implements WebMvcConfigurer {
5657

5758
private final ApplicationContext context;
5859
private final ObjectFactory<ConversionService> conversionService;
5960

60-
@Autowired private Optional<PageableHandlerMethodArgumentResolverCustomizer> pageableResolverCustomizer;
61-
@Autowired private Optional<SortHandlerMethodArgumentResolverCustomizer> sortResolverCustomizer;
61+
private @Autowired Optional<PageableHandlerMethodArgumentResolverCustomizer> pageableResolverCustomizer;
62+
private @Autowired Optional<SortHandlerMethodArgumentResolverCustomizer> sortResolverCustomizer;
6263

63-
public SpringDataWebConfiguration( //
64-
ApplicationContext context, //
65-
@Qualifier("mvcConversionService") ObjectFactory<ConversionService> conversionService //
66-
) {
64+
public SpringDataWebConfiguration(ApplicationContext context,
65+
@Qualifier("mvcConversionService") ObjectFactory<ConversionService> conversionService) {
66+
67+
Assert.notNull(context, "ApplicationContext must not be null!");
68+
Assert.notNull(conversionService, "ConversionService must not be null!");
6769

6870
this.context = context;
6971
this.conversionService = conversionService;
@@ -161,5 +163,4 @@ protected void customizePageableResolver(PageableHandlerMethodArgumentResolver p
161163
protected void customizeSortResolver(SortHandlerMethodArgumentResolver sortResolver) {
162164
sortResolverCustomizer.ifPresent(c -> c.customize(sortResolver));
163165
}
164-
165166
}

0 commit comments

Comments
 (0)
Please sign in to comment.