#857 - Use List instead of Collection in configuration classes.

This commit is contained in:
Greg Turnquist
2019-07-31 11:47:59 -05:00
parent 9ba7f0179c
commit 6d17d7e949
5 changed files with 12 additions and 15 deletions

View File

@@ -18,7 +18,6 @@ package org.springframework.hateoas.config;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
@@ -138,7 +137,7 @@ public class HateoasConfiguration {
}
@Nullable
private final Properties loadProperties(Collection<Resource> sources) {
private final Properties loadProperties(List<Resource> sources) {
Resource[] resources = loadProperties("rest-default-messages", false).stream().toArray(Resource[]::new);

View File

@@ -16,8 +16,8 @@
package org.springframework.hateoas.config;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -44,13 +44,13 @@ class HypermediaConfigurationImportSelector implements ImportSelector {
Map<String, Object> attributes = metadata.getAnnotationAttributes(EnableHypermediaSupport.class.getName());
Collection<MediaType> types = attributes == null //
List<MediaType> types = attributes == null //
? Collections.emptyList() //
: Arrays.stream((HypermediaType[]) attributes.get("type")) //
.flatMap(it -> it.getMediaTypes().stream()) //
.collect(Collectors.toList());
Collection<MediaTypeConfigurationProvider> configurationProviders = SpringFactoriesLoader.loadFactories(
List<MediaTypeConfigurationProvider> configurationProviders = SpringFactoriesLoader.loadFactories(
MediaTypeConfigurationProvider.class, HypermediaConfigurationImportSelector.class.getClassLoader());
// No additional filtering needed.
@@ -66,7 +66,7 @@ class HypermediaConfigurationImportSelector implements ImportSelector {
.toArray(String[]::new);
}
public String[] selectImports(Collection<MediaType> mediaType) {
public String[] selectImports(List<MediaType> mediaType) {
return new String[] {};
}
}

View File

@@ -18,7 +18,6 @@ package org.springframework.hateoas.config;
import lombok.RequiredArgsConstructor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.springframework.context.annotation.Configuration;
@@ -44,7 +43,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class WebClientConfigurer {
private final ObjectMapper mapper;
private final Collection<HypermediaMappingInformation> hypermediaTypes;
private final List<HypermediaMappingInformation> hypermediaTypes;
/**
* Return a set of {@link ExchangeStrategies} driven by registered {@link HypermediaType}s.

View File

@@ -17,7 +17,7 @@ package org.springframework.hateoas.config;
import lombok.RequiredArgsConstructor;
import java.util.Collection;
import java.util.List;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ObjectProvider;
@@ -50,7 +50,7 @@ class WebFluxHateoasConfiguration {
@Bean
WebClientConfigurer webClientConfigurer(ObjectProvider<ObjectMapper> mapper,
Collection<HypermediaMappingInformation> hypermediaTypes) {
List<HypermediaMappingInformation> hypermediaTypes) {
return new WebClientConfigurer(mapper.getIfAvailable(ObjectMapper::new), hypermediaTypes);
}
@@ -62,7 +62,7 @@ class WebFluxHateoasConfiguration {
@Bean
HypermediaWebFluxConfigurer hypermediaWebFluxConfigurer(ObjectProvider<ObjectMapper> mapper,
Collection<HypermediaMappingInformation> hypermediaTypes) {
List<HypermediaMappingInformation> hypermediaTypes) {
return new HypermediaWebFluxConfigurer(mapper.getIfAvailable(ObjectMapper::new), hypermediaTypes);
}
@@ -112,7 +112,7 @@ class WebFluxHateoasConfiguration {
static class HypermediaWebFluxConfigurer implements WebFluxConfigurer {
private final ObjectMapper mapper;
private final Collection<HypermediaMappingInformation> hypermediaTypes;
private final List<HypermediaMappingInformation> hypermediaTypes;
/**
* Configure custom HTTP message readers and writers or override built-in ones.

View File

@@ -17,7 +17,6 @@ package org.springframework.hateoas.config;
import lombok.RequiredArgsConstructor;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -56,7 +55,7 @@ class WebMvcHateoasConfiguration {
@Bean
HypermediaWebMvcConfigurer hypermediaWebMvcConfigurer(ObjectProvider<ObjectMapper> mapper,
Collection<HypermediaMappingInformation> hypermediaTypes) {
List<HypermediaMappingInformation> hypermediaTypes) {
return new HypermediaWebMvcConfigurer(mapper.getIfAvailable(ObjectMapper::new), hypermediaTypes);
}
@@ -97,7 +96,7 @@ class WebMvcHateoasConfiguration {
static class HypermediaWebMvcConfigurer implements WebMvcConfigurer {
private final ObjectMapper mapper;
private final Collection<HypermediaMappingInformation> hypermediaTypes;
private final List<HypermediaMappingInformation> hypermediaTypes;
/*
* (non-Javadoc)