Explicit type can be replaced by <>

Issue: SPR-13188
This commit is contained in:
Stephane Nicoll
2016-07-05 17:00:26 +02:00
parent 3096888c7d
commit 00d2606b00
1044 changed files with 3972 additions and 3893 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@ public class HttpEntity<T> {
/**
* The empty {@code HttpEntity}, with no body or headers.
*/
public static final HttpEntity<?> EMPTY = new HttpEntity<Object>();
public static final HttpEntity<?> EMPTY = new HttpEntity<>();
private final HttpHeaders headers;

View File

@@ -392,7 +392,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
* Constructs a new, empty instance of the {@code HttpHeaders} object.
*/
public HttpHeaders() {
this(new LinkedCaseInsensitiveMap<List<String>>(8, Locale.ENGLISH), false);
this(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH), false);
}
/**
@@ -402,7 +402,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
Assert.notNull(headers, "'headers' must not be null");
if (readOnly) {
Map<String, List<String>> map =
new LinkedCaseInsensitiveMap<List<String>>(headers.size(), Locale.ENGLISH);
new LinkedCaseInsensitiveMap<>(headers.size(), Locale.ENGLISH);
for (Entry<String, List<String>> entry : headers.entrySet()) {
List<String> values = Collections.unmodifiableList(entry.getValue());
map.put(entry.getKey(), values);
@@ -483,7 +483,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
* Return the value of the {@code Access-Control-Allow-Methods} response header.
*/
public List<HttpMethod> getAccessControlAllowMethods() {
List<HttpMethod> result = new ArrayList<HttpMethod>();
List<HttpMethod> result = new ArrayList<>();
String value = getFirst(ACCESS_CONTROL_ALLOW_METHODS);
if (value != null) {
String[] tokens = StringUtils.tokenizeToStringArray(value, ",", true, true);
@@ -590,7 +590,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
* as specified by the {@code Accept-Charset} header.
*/
public List<Charset> getAcceptCharset() {
List<Charset> result = new ArrayList<Charset>();
List<Charset> result = new ArrayList<>();
String value = getFirst(ACCEPT_CHARSET);
if (value != null) {
String[] tokens = value.split(",\\s*");
@@ -627,7 +627,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
public Set<HttpMethod> getAllow() {
String value = getFirst(ALLOW);
if (!StringUtils.isEmpty(value)) {
List<HttpMethod> result = new LinkedList<HttpMethod>();
List<HttpMethod> result = new LinkedList<>();
String[] tokens = value.split(",\\s*");
for (String token : tokens) {
HttpMethod resolved = HttpMethod.resolve(token);
@@ -1063,7 +1063,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
public List<String> getValuesAsList(String headerName) {
List<String> values = get(headerName);
if (values != null) {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
for (String value : values) {
if (value != null) {
String[] tokens = StringUtils.tokenizeToStringArray(value, ",");
@@ -1086,7 +1086,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
protected List<String> getETagValuesAsList(String headerName) {
List<String> values = get(headerName);
if (values != null) {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
for (String value : values) {
if (value != null) {
Matcher matcher = ETAG_HEADER_VALUE_PATTERN.matcher(value);
@@ -1163,7 +1163,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
public void add(String headerName, String headerValue) {
List<String> headerValues = this.headers.get(headerName);
if (headerValues == null) {
headerValues = new LinkedList<String>();
headerValues = new LinkedList<>();
this.headers.put(headerName, headerValues);
}
headerValues.add(headerValue);
@@ -1179,7 +1179,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
*/
@Override
public void set(String headerName, String headerValue) {
List<String> headerValues = new LinkedList<String>();
List<String> headerValues = new LinkedList<>();
headerValues.add(headerValue);
this.headers.put(headerName, headerValues);
}
@@ -1193,7 +1193,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
@Override
public Map<String, String> toSingleValueMap() {
LinkedHashMap<String, String> singleValueMap = new LinkedHashMap<String,String>(this.headers.size());
LinkedHashMap<String, String> singleValueMap = new LinkedHashMap<>(this.headers.size());
for (Entry<String, List<String>> entry : this.headers.entrySet()) {
singleValueMap.put(entry.getKey(), entry.getValue().get(0));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public enum HttpMethod {
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
private static final Map<String, HttpMethod> mappings = new HashMap<String, HttpMethod>(8);
private static final Map<String, HttpMethod> mappings = new HashMap<>(8);
static {
for (HttpMethod httpMethod : values()) {

View File

@@ -132,7 +132,7 @@ public abstract class HttpRange {
ranges = ranges.substring(BYTE_RANGE_PREFIX.length());
String[] tokens = ranges.split(",\\s*");
List<HttpRange> result = new ArrayList<HttpRange>(tokens.length);
List<HttpRange> result = new ArrayList<>(tokens.length);
for (String token : tokens) {
result.add(parseRange(token));
}
@@ -173,7 +173,7 @@ public abstract class HttpRange {
if(ranges == null || ranges.size() == 0) {
return Collections.emptyList();
}
List<ResourceRegion> regions = new ArrayList<ResourceRegion>(ranges.size());
List<ResourceRegion> regions = new ArrayList<>(ranges.size());
for(HttpRange range : ranges) {
regions.add(range.toResourceRegion(resource));
}

View File

@@ -374,7 +374,7 @@ public class MediaType extends MimeType implements Serializable {
if (!mediaType.getParameters().containsKey(PARAM_QUALITY_FACTOR)) {
return this;
}
Map<String, String> params = new LinkedHashMap<String, String>(getParameters());
Map<String, String> params = new LinkedHashMap<>(getParameters());
params.put(PARAM_QUALITY_FACTOR, mediaType.getParameters().get(PARAM_QUALITY_FACTOR));
return new MediaType(this, params);
}
@@ -387,7 +387,7 @@ public class MediaType extends MimeType implements Serializable {
if (!getParameters().containsKey(PARAM_QUALITY_FACTOR)) {
return this;
}
Map<String, String> params = new LinkedHashMap<String, String>(getParameters());
Map<String, String> params = new LinkedHashMap<>(getParameters());
params.remove(PARAM_QUALITY_FACTOR);
return new MediaType(this, params);
}
@@ -438,7 +438,7 @@ public class MediaType extends MimeType implements Serializable {
return Collections.emptyList();
}
String[] tokens = mediaTypes.split(",\\s*");
List<MediaType> result = new ArrayList<MediaType>(tokens.length);
List<MediaType> result = new ArrayList<>(tokens.length);
for (String token : tokens) {
result.add(parseMediaType(token));
}
@@ -525,7 +525,7 @@ public class MediaType extends MimeType implements Serializable {
public static void sortBySpecificityAndQuality(List<MediaType> mediaTypes) {
Assert.notNull(mediaTypes, "'mediaTypes' must not be null");
if (mediaTypes.size() > 1) {
Collections.sort(mediaTypes, new CompoundComparator<MediaType>(
Collections.sort(mediaTypes, new CompoundComparator<>(
MediaType.SPECIFICITY_COMPARATOR, MediaType.QUALITY_VALUE_COMPARATOR));
}
}

View File

@@ -444,17 +444,17 @@ public class RequestEntity<T> extends HttpEntity<T> {
@Override
public RequestEntity<Void> build() {
return new RequestEntity<Void>(this.headers, this.method, this.url);
return new RequestEntity<>(this.headers, this.method, this.url);
}
@Override
public <T> RequestEntity<T> body(T body) {
return new RequestEntity<T>(body, this.headers, this.method, this.url);
return new RequestEntity<>(body, this.headers, this.method, this.url);
}
@Override
public <T> RequestEntity<T> body(T body, Type type) {
return new RequestEntity<T>(body, this.headers, this.method, this.url, type);
return new RequestEntity<>(body, this.headers, this.method, this.url, type);
}
}

View File

@@ -447,7 +447,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
@Override
public BodyBuilder allow(HttpMethod... allowedMethods) {
this.headers.setAllow(new LinkedHashSet<HttpMethod>(Arrays.asList(allowedMethods)));
this.headers.setAllow(new LinkedHashSet<>(Arrays.asList(allowedMethods)));
return this;
}
@@ -511,7 +511,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
@Override
public <T> ResponseEntity<T> body(T body) {
return new ResponseEntity<T>(body, this.headers, this.statusCode);
return new ResponseEntity<>(body, this.headers, this.statusCode);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -102,7 +102,7 @@ final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncC
private static class HttpResponseFutureCallback implements FutureCallback<HttpResponse> {
private final ListenableFutureCallbackRegistry<ClientHttpResponse> callbacks =
new ListenableFutureCallbackRegistry<ClientHttpResponse>();
new ListenableFutureCallbackRegistry<>();
public void addCallback(ListenableFutureCallback<? super ClientHttpResponse> callback) {
this.callbacks.addCallback(callback);

View File

@@ -88,7 +88,7 @@ class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements
@Override
protected ListenableFuture<ClientHttpResponse> executeInternal(final HttpHeaders headers) throws IOException {
final SettableListenableFuture<ClientHttpResponse> responseFuture =
new SettableListenableFuture<ClientHttpResponse>();
new SettableListenableFuture<>();
ChannelFutureListener connectionListener = new ChannelFutureListener() {
@Override

View File

@@ -35,7 +35,7 @@ import org.springframework.util.CollectionUtils;
public abstract class InterceptingAsyncHttpAccessor extends AsyncHttpAccessor {
private List<AsyncClientHttpRequestInterceptor> interceptors =
new ArrayList<AsyncClientHttpRequestInterceptor>();
new ArrayList<>();
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ import org.springframework.util.CollectionUtils;
*/
public abstract class InterceptingHttpAccessor extends HttpAccessor {
private List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>();
private List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>();
/**
* Sets the request interceptors that this accessor should use.

View File

@@ -97,7 +97,7 @@ public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConv
*/
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
Assert.notEmpty(supportedMediaTypes, "'supportedMediaTypes' must not be empty");
this.supportedMediaTypes = new ArrayList<MediaType>(supportedMediaTypes);
this.supportedMediaTypes = new ArrayList<>(supportedMediaTypes);
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -67,7 +67,7 @@ import org.springframework.util.StringUtils;
*/
public class BufferedImageHttpMessageConverter implements HttpMessageConverter<BufferedImage> {
private final List<MediaType> readableMediaTypes = new ArrayList<MediaType>();
private final List<MediaType> readableMediaTypes = new ArrayList<>();
private MediaType defaultContentType;

View File

@@ -91,9 +91,9 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
private List<MediaType> supportedMediaTypes = new ArrayList<MediaType>();
private List<MediaType> supportedMediaTypes = new ArrayList<>();
private List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
private List<HttpMessageConverter<?>> partConverters = new ArrayList<>();
private Charset charset = DEFAULT_CHARSET;
@@ -230,7 +230,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
String body = StreamUtils.copyToString(inputMessage.getBody(), charset);
String[] pairs = StringUtils.tokenizeToStringArray(body, "&");
MultiValueMap<String, String> result = new LinkedMultiValueMap<String, String>(pairs.length);
MultiValueMap<String, String> result = new LinkedMultiValueMap<>(pairs.length);
for (String pair : pairs) {
int idx = pair.indexOf('=');
if (idx == -1) {
@@ -399,7 +399,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
return (HttpEntity<?>) part;
}
else {
return new HttpEntity<Object>(part);
return new HttpEntity<>(part);
}
}

View File

@@ -62,7 +62,7 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter<Str
*/
public StringHttpMessageConverter(Charset defaultCharset) {
super(defaultCharset, MediaType.TEXT_PLAIN, MediaType.ALL);
this.availableCharsets = new ArrayList<Charset>(Charset.availableCharsets().values());
this.availableCharsets = new ArrayList<>(Charset.availableCharsets().values());
}

View File

@@ -145,7 +145,7 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
if (!logger.isWarnEnabled()) {
return this.objectMapper.canDeserialize(javaType);
}
AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
AtomicReference<Throwable> causeRef = new AtomicReference<>();
if (this.objectMapper.canDeserialize(javaType, causeRef)) {
return true;
}
@@ -161,7 +161,7 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
if (!logger.isWarnEnabled()) {
return this.objectMapper.canSerialize(clazz);
}
AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
AtomicReference<Throwable> causeRef = new AtomicReference<>();
if (this.objectMapper.canSerialize(clazz, causeRef)) {
return true;
}

View File

@@ -108,13 +108,13 @@ public class Jackson2ObjectMapperBuilder {
private FilterProvider filters;
private final Map<Class<?>, Class<?>> mixIns = new HashMap<Class<?>, Class<?>>();
private final Map<Class<?>, Class<?>> mixIns = new HashMap<>();
private final Map<Class<?>, JsonSerializer<?>> serializers = new LinkedHashMap<Class<?>, JsonSerializer<?>>();
private final Map<Class<?>, JsonSerializer<?>> serializers = new LinkedHashMap<>();
private final Map<Class<?>, JsonDeserializer<?>> deserializers = new LinkedHashMap<Class<?>, JsonDeserializer<?>>();
private final Map<Class<?>, JsonDeserializer<?>> deserializers = new LinkedHashMap<>();
private final Map<Object, Boolean> features = new HashMap<Object, Boolean>();
private final Map<Object, Boolean> features = new HashMap<>();
private List<Module> modules;
@@ -485,7 +485,7 @@ public class Jackson2ObjectMapperBuilder {
* @see com.fasterxml.jackson.databind.Module
*/
public Jackson2ObjectMapperBuilder modules(List<Module> modules) {
this.modules = new LinkedList<Module>(modules);
this.modules = new LinkedList<>(modules);
this.findModulesViaServiceLoader = false;
this.findWellKnownModules = false;
return this;

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -74,7 +74,7 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<M
private static final ProtobufFormatter HTML_FORMAT = new HtmlFormat();
private static final ConcurrentHashMap<Class<?>, Method> methodCache = new ConcurrentHashMap<Class<?>, Method>();
private static final ConcurrentHashMap<Class<?>, Method> methodCache = new ConcurrentHashMap<>();
private final ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();

View File

@@ -51,7 +51,7 @@ public class AllEncompassingFormHttpMessageConverter extends FormHttpMessageConv
public AllEncompassingFormHttpMessageConverter() {
addPartConverter(new SourceHttpMessageConverter<Source>());
addPartConverter(new SourceHttpMessageConverter<>());
if (jaxb2Present && !jackson2XmlPresent) {
addPartConverter(new Jaxb2RootElementHttpMessageConverter());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ import org.springframework.util.Assert;
*/
public abstract class AbstractJaxb2HttpMessageConverter<T> extends AbstractXmlHttpMessageConverter<T> {
private final ConcurrentMap<Class<?>, JAXBContext> jaxbContexts = new ConcurrentHashMap<Class<?>, JAXBContext>(64);
private final ConcurrentMap<Class<?>, JAXBContext> jaxbContexts = new ConcurrentHashMap<>(64);
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@ import org.springframework.util.StreamUtils;
*/
public class SourceHttpMessageConverter<T extends Source> extends AbstractHttpMessageConverter<T> {
private static final Set<Class<?>> SUPPORTED_CLASSES = new HashSet<Class<?>>(5);
private static final Set<Class<?>> SUPPORTED_CLASSES = new HashSet<>(5);
static {
SUPPORTED_CLASSES.add(DOMSource.class);

View File

@@ -129,7 +129,7 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
String requestEncoding = this.servletRequest.getCharacterEncoding();
if (StringUtils.hasLength(requestEncoding)) {
Charset charSet = Charset.forName(requestEncoding);
Map<String, String> params = new LinkedCaseInsensitiveMap<String>();
Map<String, String> params = new LinkedCaseInsensitiveMap<>();
params.putAll(contentType.getParameters());
params.put("charset", charSet.toString());
MediaType newContentType = new MediaType(contentType.getType(), contentType.getSubtype(), params);

View File

@@ -163,7 +163,7 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
return null;
}
List<String> values = new ArrayList<String>();
List<String> values = new ArrayList<>();
if (!isEmpty1) {
values.addAll(values1);
}

View File

@@ -60,7 +60,7 @@ public abstract class AbstractJaxWsServiceExporter implements BeanFactoryAware,
private ListableBeanFactory beanFactory;
private final Set<Endpoint> publishedEndpoints = new LinkedHashSet<Endpoint>();
private final Set<Endpoint> publishedEndpoints = new LinkedHashSet<>();
/**
@@ -127,7 +127,7 @@ public abstract class AbstractJaxWsServiceExporter implements BeanFactoryAware,
* @see #publishEndpoint
*/
public void publishEndpoints() {
Set<String> beanNames = new LinkedHashSet<String>(this.beanFactory.getBeanDefinitionCount());
Set<String> beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount());
beanNames.addAll(Arrays.asList(this.beanFactory.getBeanDefinitionNames()));
if (this.beanFactory instanceof ConfigurableBeanFactory) {
beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));

View File

@@ -240,7 +240,7 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory
*/
public Map<String, Object> getCustomProperties() {
if (this.customProperties == null) {
this.customProperties = new HashMap<String, Object>();
this.customProperties = new HashMap<>();
}
return this.customProperties;
}
@@ -427,7 +427,7 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory
* @see #setCustomProperties
*/
protected void preparePortStub(Object stub) {
Map<String, Object> stubProperties = new HashMap<String, Object>();
Map<String, Object> stubProperties = new HashMap<>();
String username = getUsername();
if (username != null) {
stubProperties.put(BindingProvider.USERNAME_PROPERTY, username);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -106,7 +106,7 @@ public class HttpRequestMethodNotSupportedException extends ServletException {
* Return the actually supported HTTP methods, if known, as {@link HttpMethod} instances.
*/
public Set<HttpMethod> getSupportedHttpMethods() {
List<HttpMethod> supportedMethods = new LinkedList<HttpMethod>();
List<HttpMethod> supportedMethods = new LinkedList<>();
for (String value : this.supportedMethods) {
HttpMethod resolved = HttpMethod.resolve(value);
if (resolved != null) {

View File

@@ -140,7 +140,7 @@ public class SpringServletContainerInitializer implements ServletContainerInitia
public void onStartup(Set<Class<?>> webAppInitializerClasses, ServletContext servletContext)
throws ServletException {
List<WebApplicationInitializer> initializers = new LinkedList<WebApplicationInitializer>();
List<WebApplicationInitializer> initializers = new LinkedList<>();
if (webAppInitializerClasses != null) {
for (Class<?> waiClass : webAppInitializerClasses) {

View File

@@ -46,9 +46,9 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy, Me
private static final List<MediaType> MEDIA_TYPE_ALL = Collections.<MediaType>singletonList(MediaType.ALL);
private final List<ContentNegotiationStrategy> strategies = new ArrayList<ContentNegotiationStrategy>();
private final List<ContentNegotiationStrategy> strategies = new ArrayList<>();
private final Set<MediaTypeFileExtensionResolver> resolvers = new LinkedHashSet<MediaTypeFileExtensionResolver>();
private final Set<MediaTypeFileExtensionResolver> resolvers = new LinkedHashSet<>();
/**
@@ -133,11 +133,11 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy, Me
@Override
public List<String> resolveFileExtensions(MediaType mediaType) {
Set<String> result = new LinkedHashSet<String>();
Set<String> result = new LinkedHashSet<>();
for (MediaTypeFileExtensionResolver resolver : this.resolvers) {
result.addAll(resolver.resolveFileExtensions(mediaType));
}
return new ArrayList<String>(result);
return new ArrayList<>(result);
}
/**
@@ -152,11 +152,11 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy, Me
*/
@Override
public List<String> getAllFileExtensions() {
Set<String> result = new LinkedHashSet<String>();
Set<String> result = new LinkedHashSet<>();
for (MediaTypeFileExtensionResolver resolver : this.resolvers) {
result.addAll(resolver.getAllFileExtensions());
}
return new ArrayList<String>(result);
return new ArrayList<>(result);
}
}

View File

@@ -96,7 +96,7 @@ public class ContentNegotiationManagerFactoryBean
private boolean ignoreAcceptHeader = false;
private Map<String, MediaType> mediaTypes = new HashMap<String, MediaType>();
private Map<String, MediaType> mediaTypes = new HashMap<>();
private boolean ignoreUnknownPathExtensions = true;
@@ -250,7 +250,7 @@ public class ContentNegotiationManagerFactoryBean
@Override
public void afterPropertiesSet() {
List<ContentNegotiationStrategy> strategies = new ArrayList<ContentNegotiationStrategy>();
List<ContentNegotiationStrategy> strategies = new ArrayList<>();
if (this.favorPathExtension) {
PathExtensionContentNegotiationStrategy strategy;

View File

@@ -43,12 +43,12 @@ import org.springframework.util.MultiValueMap;
public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExtensionResolver {
private final ConcurrentMap<String, MediaType> mediaTypes =
new ConcurrentHashMap<String, MediaType>(64);
new ConcurrentHashMap<>(64);
private final MultiValueMap<MediaType, String> fileExtensions =
new LinkedMultiValueMap<MediaType, String>();
new LinkedMultiValueMap<>();
private final List<String> allFileExtensions = new LinkedList<String>();
private final List<String> allFileExtensions = new LinkedList<>();
/**
@@ -68,7 +68,7 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten
protected List<MediaType> getAllMediaTypes() {
return new ArrayList<MediaType>(this.mediaTypes.values());
return new ArrayList<>(this.mediaTypes.values());
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -230,7 +230,7 @@ public class EscapedErrors implements Errors {
}
private <T extends ObjectError> List<T> escapeObjectErrors(List<T> source) {
List<T> escaped = new ArrayList<T>(source.size());
List<T> escaped = new ArrayList<>(source.size());
for (T objectError : source) {
escaped.add(escapeObjectError(objectError));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -134,7 +134,7 @@ public class WebRequestDataBinder extends WebDataBinder {
private void bindParts(HttpServletRequest request, MutablePropertyValues mpvs) {
try {
MultiValueMap<String, Part> map = new LinkedMultiValueMap<String, Part>();
MultiValueMap<String, Part> map = new LinkedMultiValueMap<>();
for (Part part : request.getParts()) {
map.add(part.getName(), part);
}

View File

@@ -503,7 +503,7 @@ public class AsyncRestTemplate extends InterceptingAsyncHttpAccessor implements
requestCallback.doWithRequest(request);
}
ListenableFuture<ClientHttpResponse> responseFuture = request.executeAsync();
return new ResponseExtractorFuture<T>(method, url, responseFuture, responseExtractor);
return new ResponseExtractorFuture<>(method, url, responseFuture, responseExtractor);
}
catch (IOException ex) {
throw new ResourceAccessException("I/O error on " + method.name() +

View File

@@ -138,7 +138,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
ClassUtils.isPresent("com.google.gson.Gson", RestTemplate.class.getClassLoader());
private final List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
private final List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
private ResponseErrorHandler errorHandler = new DefaultResponseErrorHandler();
@@ -155,7 +155,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
this.messageConverters.add(new ByteArrayHttpMessageConverter());
this.messageConverters.add(new StringHttpMessageConverter());
this.messageConverters.add(new ResourceHttpMessageConverter());
this.messageConverters.add(new SourceHttpMessageConverter<Source>());
this.messageConverters.add(new SourceHttpMessageConverter<>());
this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
if (romePresent) {
@@ -283,7 +283,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) throws RestClientException {
RequestCallback requestCallback = acceptHeaderRequestCallback(responseType);
HttpMessageConverterExtractor<T> responseExtractor =
new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
return execute(url, HttpMethod.GET, requestCallback, responseExtractor, urlVariables);
}
@@ -291,7 +291,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
public <T> T getForObject(String url, Class<T> responseType, Map<String, ?> urlVariables) throws RestClientException {
RequestCallback requestCallback = acceptHeaderRequestCallback(responseType);
HttpMessageConverterExtractor<T> responseExtractor =
new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
return execute(url, HttpMethod.GET, requestCallback, responseExtractor, urlVariables);
}
@@ -299,7 +299,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
public <T> T getForObject(URI url, Class<T> responseType) throws RestClientException {
RequestCallback requestCallback = acceptHeaderRequestCallback(responseType);
HttpMessageConverterExtractor<T> responseExtractor =
new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
return execute(url, HttpMethod.GET, requestCallback, responseExtractor);
}
@@ -376,7 +376,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
RequestCallback requestCallback = httpEntityCallback(request, responseType);
HttpMessageConverterExtractor<T> responseExtractor =
new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
return execute(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables);
}
@@ -386,7 +386,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
RequestCallback requestCallback = httpEntityCallback(request, responseType);
HttpMessageConverterExtractor<T> responseExtractor =
new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
return execute(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables);
}
@@ -394,7 +394,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
public <T> T postForObject(URI url, Object request, Class<T> responseType) throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request, responseType);
HttpMessageConverterExtractor<T> responseExtractor =
new HttpMessageConverterExtractor<T>(responseType, getMessageConverters());
new HttpMessageConverterExtractor<>(responseType, getMessageConverters());
return execute(url, HttpMethod.POST, requestCallback, responseExtractor);
}
@@ -697,7 +697,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
* Returns a response extractor for {@link ResponseEntity}.
*/
protected <T> ResponseExtractor<ResponseEntity<T>> responseEntityExtractor(Type responseType) {
return new ResponseEntityResponseExtractor<T>(responseType);
return new ResponseEntityResponseExtractor<>(responseType);
}
/**
@@ -726,7 +726,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
if (this.responseType instanceof Class) {
responseClass = (Class<?>) this.responseType;
}
List<MediaType> allSupportedMediaTypes = new ArrayList<MediaType>();
List<MediaType> allSupportedMediaTypes = new ArrayList<>();
for (HttpMessageConverter<?> converter : getMessageConverters()) {
if (responseClass != null) {
if (converter.canRead(responseClass, null)) {
@@ -752,7 +752,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
private List<MediaType> getSupportedMediaTypes(HttpMessageConverter<?> messageConverter) {
List<MediaType> supportedMediaTypes = messageConverter.getSupportedMediaTypes();
List<MediaType> result = new ArrayList<MediaType>(supportedMediaTypes.size());
List<MediaType> result = new ArrayList<>(supportedMediaTypes.size());
for (MediaType supportedMediaType : supportedMediaTypes) {
if (supportedMediaType.getCharset() != null) {
supportedMediaType =
@@ -782,7 +782,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
this.requestEntity = (HttpEntity<?>) requestBody;
}
else if (requestBody != null) {
this.requestEntity = new HttpEntity<Object>(requestBody);
this.requestEntity = new HttpEntity<>(requestBody);
}
else {
this.requestEntity = HttpEntity.EMPTY;
@@ -871,7 +871,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
public ResponseEntityResponseExtractor(Type responseType) {
if (responseType != null && Void.class != responseType) {
this.delegate = new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
this.delegate = new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger);
}
else {
this.delegate = null;
@@ -882,10 +882,10 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
public ResponseEntity<T> extractData(ClientHttpResponse response) throws IOException {
if (this.delegate != null) {
T body = this.delegate.extractData(response);
return new ResponseEntity<T>(body, response.getHeaders(), response.getStatusCode());
return new ResponseEntity<>(body, response.getHeaders(), response.getStatusCode());
}
else {
return new ResponseEntity<T>(response.getHeaders(), response.getStatusCode());
return new ResponseEntity<>(response.getHeaders(), response.getStatusCode());
}
}
}

View File

@@ -183,7 +183,7 @@ public class ContextLoader {
* Map from (thread context) ClassLoader to corresponding 'current' WebApplicationContext.
*/
private static final Map<ClassLoader, WebApplicationContext> currentContextPerThread =
new ConcurrentHashMap<ClassLoader, WebApplicationContext>(1);
new ConcurrentHashMap<>(1);
/**
* The 'current' WebApplicationContext, if the ContextLoader class is
@@ -205,7 +205,7 @@ public class ContextLoader {
/** Actual ApplicationContextInitializer instances to apply to the context */
private final List<ApplicationContextInitializer<ConfigurableApplicationContext>> contextInitializers =
new ArrayList<ApplicationContextInitializer<ConfigurableApplicationContext>>();
new ArrayList<>();
/**
@@ -494,7 +494,7 @@ public class ContextLoader {
determineContextInitializerClasses(ServletContext servletContext) {
List<Class<ApplicationContextInitializer<ConfigurableApplicationContext>>> classes =
new ArrayList<Class<ApplicationContextInitializer<ConfigurableApplicationContext>>>();
new ArrayList<>();
String globalClassNames = servletContext.getInitParameter(GLOBAL_INITIALIZER_CLASSES_PARAM);
if (globalClassNames != null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ import org.springframework.util.Assert;
public abstract class AbstractRequestAttributes implements RequestAttributes {
/** Map from attribute name String to destruction callback Runnable */
protected final Map<String, Runnable> requestDestructionCallbacks = new LinkedHashMap<String, Runnable>(8);
protected final Map<String, Runnable> requestDestructionCallbacks = new LinkedHashMap<>(8);
private volatile boolean requestActive = true;

View File

@@ -47,10 +47,10 @@ public abstract class RequestContextHolder {
ClassUtils.isPresent("javax.faces.context.FacesContext", RequestContextHolder.class.getClassLoader());
private static final ThreadLocal<RequestAttributes> requestAttributesHolder =
new NamedThreadLocal<RequestAttributes>("Request attributes");
new NamedThreadLocal<>("Request attributes");
private static final ThreadLocal<RequestAttributes> inheritableRequestAttributesHolder =
new NamedInheritableThreadLocal<RequestAttributes>("Request context");
new NamedInheritableThreadLocal<>("Request context");
/**

View File

@@ -49,7 +49,7 @@ public class ServletRequestAttributes extends AbstractRequestAttributes {
public static final String DESTRUCTION_CALLBACK_NAME_PREFIX =
ServletRequestAttributes.class.getName() + ".DESTRUCTION_CALLBACK.";
protected static final Set<Class<?>> immutableValueTypes = new HashSet<Class<?>>(16);
protected static final Set<Class<?>> immutableValueTypes = new HashSet<>(16);
static {
immutableValueTypes.addAll(NumberUtils.STANDARD_NUMBER_TYPES);
@@ -65,7 +65,7 @@ public class ServletRequestAttributes extends AbstractRequestAttributes {
private volatile HttpSession session;
private final Map<String, Object> sessionAttributesToUpdate = new ConcurrentHashMap<String, Object>(1);
private final Map<String, Object> sessionAttributesToUpdate = new ConcurrentHashMap<>(1);
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,9 +48,9 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
private AtomicBoolean asyncCompleted = new AtomicBoolean(false);
private final List<Runnable> timeoutHandlers = new ArrayList<Runnable>();
private final List<Runnable> timeoutHandlers = new ArrayList<>();
private final List<Runnable> completionHandlers = new ArrayList<Runnable>();
private final List<Runnable> completionHandlers = new ArrayList<>();
/**

View File

@@ -79,10 +79,10 @@ public final class WebAsyncManager {
private Object[] concurrentResultContext;
private final Map<Object, CallableProcessingInterceptor> callableInterceptors =
new LinkedHashMap<Object, CallableProcessingInterceptor>();
new LinkedHashMap<>();
private final Map<Object, DeferredResultProcessingInterceptor> deferredResultInterceptors =
new LinkedHashMap<Object, DeferredResultProcessingInterceptor>();
new LinkedHashMap<>();
/**
@@ -279,7 +279,7 @@ public final class WebAsyncManager {
this.taskExecutor = executor;
}
List<CallableProcessingInterceptor> interceptors = new ArrayList<CallableProcessingInterceptor>();
List<CallableProcessingInterceptor> interceptors = new ArrayList<>();
interceptors.add(webAsyncTask.getInterceptor());
interceptors.addAll(this.callableInterceptors.values());
interceptors.add(timeoutCallableInterceptor);
@@ -379,7 +379,7 @@ public final class WebAsyncManager {
this.asyncWebRequest.setTimeout(timeout);
}
List<DeferredResultProcessingInterceptor> interceptors = new ArrayList<DeferredResultProcessingInterceptor>();
List<DeferredResultProcessingInterceptor> interceptors = new ArrayList<>();
interceptors.add(deferredResult.getInterceptor());
interceptors.addAll(this.deferredResultInterceptors.values());
interceptors.add(timeoutDeferredResultInterceptor);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,9 +86,9 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe
private ScopeMetadataResolver scopeMetadataResolver;
private final Set<Class<?>> annotatedClasses = new LinkedHashSet<Class<?>>();
private final Set<Class<?>> annotatedClasses = new LinkedHashSet<>();
private final Set<String> basePackages = new LinkedHashSet<String>();
private final Set<String> basePackages = new LinkedHashSet<>();
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -92,7 +92,7 @@ public class ContextExposingHttpServletRequest extends HttpServletRequestWrapper
public void setAttribute(String name, Object value) {
super.setAttribute(name, value);
if (this.explicitAttributes == null) {
this.explicitAttributes = new HashSet<String>(8);
this.explicitAttributes = new HashSet<>(8);
}
this.explicitAttributes.add(name);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ public class ServletContextLiveBeansView extends LiveBeansView {
@Override
protected Set<ConfigurableApplicationContext> findApplicationContexts() {
Set<ConfigurableApplicationContext> contexts = new LinkedHashSet<ConfigurableApplicationContext>();
Set<ConfigurableApplicationContext> contexts = new LinkedHashSet<>();
Enumeration<String> attrNames = this.servletContext.getAttributeNames();
while (attrNames.hasMoreElements()) {
String attrName = attrNames.nextElement();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@ public class ServletContextResourcePatternResolver extends PathMatchingResourceP
ServletContextResource scResource = (ServletContextResource) rootDirResource;
ServletContext sc = scResource.getServletContext();
String fullPattern = scResource.getPath() + subPattern;
Set<Resource> result = new LinkedHashSet<Resource>(8);
Set<Resource> result = new LinkedHashSet<>(8);
doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result);
return result;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ public class ServletContextScope implements Scope, DisposableBean {
private final ServletContext servletContext;
private final Map<String, Runnable> destructionCallbacks = new LinkedHashMap<String, Runnable>();
private final Map<String, Runnable> destructionCallbacks = new LinkedHashMap<>();
/**

View File

@@ -223,7 +223,7 @@ public abstract class WebApplicationContextUtils {
}
if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) {
Map<String, String> parameterMap = new HashMap<String, String>();
Map<String, String> parameterMap = new HashMap<>();
if (servletContext != null) {
Enumeration<?> paramNameEnum = servletContext.getInitParameterNames();
while (paramNameEnum.hasMoreElements()) {
@@ -243,7 +243,7 @@ public abstract class WebApplicationContextUtils {
}
if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
Map<String, Object> attributeMap = new HashMap<>();
if (servletContext != null) {
Enumeration<?> attrNameEnum = servletContext.getAttributeNames();
while (attrNameEnum.hasMoreElements()) {

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -108,7 +108,7 @@ public class CorsConfiguration {
if (source == null || source.contains(ALL)) {
return other;
}
List<String> combined = new ArrayList<String>(source);
List<String> combined = new ArrayList<>(source);
combined.addAll(other);
return combined;
}
@@ -120,7 +120,7 @@ public class CorsConfiguration {
* <p>By default this is not set.
*/
public void setAllowedOrigins(List<String> allowedOrigins) {
this.allowedOrigins = (allowedOrigins != null ? new ArrayList<String>(allowedOrigins) : null);
this.allowedOrigins = (allowedOrigins != null ? new ArrayList<>(allowedOrigins) : null);
}
/**
@@ -137,7 +137,7 @@ public class CorsConfiguration {
*/
public void addAllowedOrigin(String origin) {
if (this.allowedOrigins == null) {
this.allowedOrigins = new ArrayList<String>();
this.allowedOrigins = new ArrayList<>();
}
this.allowedOrigins.add(origin);
}
@@ -150,7 +150,7 @@ public class CorsConfiguration {
* <p>By default this is not set.
*/
public void setAllowedMethods(List<String> allowedMethods) {
this.allowedMethods = (allowedMethods != null ? new ArrayList<String>(allowedMethods) : null);
this.allowedMethods = (allowedMethods != null ? new ArrayList<>(allowedMethods) : null);
}
/**
@@ -179,7 +179,7 @@ public class CorsConfiguration {
public void addAllowedMethod(String method) {
if (StringUtils.hasText(method)) {
if (this.allowedMethods == null) {
this.allowedMethods = new ArrayList<String>();
this.allowedMethods = new ArrayList<>();
}
this.allowedMethods.add(method);
}
@@ -196,7 +196,7 @@ public class CorsConfiguration {
* <p>By default this is not set.
*/
public void setAllowedHeaders(List<String> allowedHeaders) {
this.allowedHeaders = (allowedHeaders != null ? new ArrayList<String>(allowedHeaders) : null);
this.allowedHeaders = (allowedHeaders != null ? new ArrayList<>(allowedHeaders) : null);
}
/**
@@ -213,7 +213,7 @@ public class CorsConfiguration {
*/
public void addAllowedHeader(String allowedHeader) {
if (this.allowedHeaders == null) {
this.allowedHeaders = new ArrayList<String>();
this.allowedHeaders = new ArrayList<>();
}
this.allowedHeaders.add(allowedHeader);
}
@@ -230,7 +230,7 @@ public class CorsConfiguration {
if (exposedHeaders != null && exposedHeaders.contains(ALL)) {
throw new IllegalArgumentException("'*' is not a valid exposed header value");
}
this.exposedHeaders = (exposedHeaders == null ? null : new ArrayList<String>(exposedHeaders));
this.exposedHeaders = (exposedHeaders == null ? null : new ArrayList<>(exposedHeaders));
}
/**
@@ -251,7 +251,7 @@ public class CorsConfiguration {
throw new IllegalArgumentException("'*' is not a valid exposed header value");
}
if (this.exposedHeaders == null) {
this.exposedHeaders = new ArrayList<String>();
this.exposedHeaders = new ArrayList<>();
}
this.exposedHeaders.add(exposedHeader);
}
@@ -334,7 +334,7 @@ public class CorsConfiguration {
return null;
}
List<String> allowedMethods =
(this.allowedMethods != null ? this.allowedMethods : new ArrayList<String>());
(this.allowedMethods != null ? this.allowedMethods : new ArrayList<>());
if (allowedMethods.contains(ALL)) {
return Collections.singletonList(requestMethod);
}
@@ -342,7 +342,7 @@ public class CorsConfiguration {
allowedMethods.add(HttpMethod.GET.name());
allowedMethods.add(HttpMethod.HEAD.name());
}
List<HttpMethod> result = new ArrayList<HttpMethod>(allowedMethods.size());
List<HttpMethod> result = new ArrayList<>(allowedMethods.size());
boolean allowed = false;
for (String method : allowedMethods) {
if (requestMethod.matches(method)) {
@@ -376,7 +376,7 @@ public class CorsConfiguration {
}
boolean allowAnyHeader = this.allowedHeaders.contains(ALL);
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
for (String requestHeader : requestHeaders) {
if (StringUtils.hasText(requestHeader)) {
requestHeader = requestHeader.trim();

View File

@@ -193,7 +193,7 @@ public class DefaultCorsProcessor implements CorsProcessor {
private List<String> getHeadersToUse(ServerHttpRequest request, boolean isPreFlight) {
HttpHeaders headers = request.getHeaders();
return (isPreFlight ? headers.getAccessControlRequestHeaders() : new ArrayList<String>(headers.keySet()));
return (isPreFlight ? headers.getAccessControlRequestHeaders() : new ArrayList<>(headers.keySet()));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ import org.springframework.web.util.UrlPathHelper;
*/
public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource {
private final Map<String, CorsConfiguration> corsConfigurations = new LinkedHashMap<String, CorsConfiguration>();
private final Map<String, CorsConfiguration> corsConfigurations = new LinkedHashMap<>();
private PathMatcher pathMatcher = new AntPathMatcher();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ import javax.servlet.ServletResponse;
*/
public class CompositeFilter implements Filter {
private List<? extends Filter> filters = new ArrayList<Filter>();
private List<? extends Filter> filters = new ArrayList<>();
public void setFilters(List<? extends Filter> filters) {

View File

@@ -53,7 +53,7 @@ import org.springframework.web.util.UrlPathHelper;
public class ForwardedHeaderFilter extends OncePerRequestFilter {
private static final Set<String> FORWARDED_HEADER_NAMES =
Collections.newSetFromMap(new LinkedCaseInsensitiveMap<Boolean>(5, Locale.ENGLISH));
Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(5, Locale.ENGLISH));
static {
FORWARDED_HEADER_NAMES.add("Forwarded");
@@ -156,7 +156,7 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter {
* Copy the headers excluding any {@link #FORWARDED_HEADER_NAMES}.
*/
private static Map<String, List<String>> initHeaders(HttpServletRequest request) {
Map<String, List<String>> headers = new LinkedCaseInsensitiveMap<List<String>>(Locale.ENGLISH);
Map<String, List<String>> headers = new LinkedCaseInsensitiveMap<>(Locale.ENGLISH);
Enumeration<String> names = request.getHeaderNames();
while (names.hasMoreElements()) {
String name = names.nextElement();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -85,7 +85,7 @@ public abstract class GenericFilterBean implements
* Set of required properties (Strings) that must be supplied as
* config parameters to this filter.
*/
private final Set<String> requiredProperties = new HashSet<String>();
private final Set<String> requiredProperties = new HashSet<>();
private FilterConfig filterConfig;
@@ -301,7 +301,7 @@ public abstract class GenericFilterBean implements
throws ServletException {
Set<String> missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ?
new HashSet<String>(requiredProperties) : null;
new HashSet<>(requiredProperties) : null;
Enumeration<?> en = config.getInitParameterNames();
while (en.hasMoreElements()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -110,7 +110,7 @@ public class HttpPutFormContentFilter extends OncePerRequestFilter {
public HttpPutFormContentRequestWrapper(HttpServletRequest request, MultiValueMap<String, String> parameters) {
super(request);
this.formParameters = (parameters != null) ? parameters : new LinkedMultiValueMap<String, String>();
this.formParameters = (parameters != null) ? parameters : new LinkedMultiValueMap<>();
}
@Override
@@ -122,7 +122,7 @@ public class HttpPutFormContentFilter extends OncePerRequestFilter {
@Override
public Map<String, String[]> getParameterMap() {
Map<String, String[]> result = new LinkedHashMap<String, String[]>();
Map<String, String[]> result = new LinkedHashMap<>();
Enumeration<String> names = this.getParameterNames();
while (names.hasMoreElements()) {
String name = names.nextElement();
@@ -133,7 +133,7 @@ public class HttpPutFormContentFilter extends OncePerRequestFilter {
@Override
public Enumeration<String> getParameterNames() {
Set<String> names = new LinkedHashSet<String>();
Set<String> names = new LinkedHashSet<>();
names.addAll(Collections.list(super.getParameterNames()));
names.addAll(this.formParameters.keySet());
return Collections.enumeration(names);
@@ -150,7 +150,7 @@ public class HttpPutFormContentFilter extends OncePerRequestFilter {
return formValues.toArray(new String[formValues.size()]);
}
else {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
result.addAll(Arrays.asList(queryStringValues));
result.addAll(formValues);
return result.toArray(new String[result.size()]);

View File

@@ -211,7 +211,7 @@ public class ControllerAdviceBean implements Ordered {
* ApplicationContext and wrap them as {@code ControllerAdviceBean} instances.
*/
public static List<ControllerAdviceBean> findAnnotatedBeans(ApplicationContext applicationContext) {
List<ControllerAdviceBean> beans = new ArrayList<ControllerAdviceBean>();
List<ControllerAdviceBean> beans = new ArrayList<>();
for (String name : BeanFactoryUtils.beanNamesForTypeIncludingAncestors(applicationContext, Object.class)) {
if (applicationContext.findAnnotationOnBean(name, ControllerAdvice.class) != null) {
beans.add(new ControllerAdviceBean(name, applicationContext));
@@ -229,7 +229,7 @@ public class ControllerAdviceBean implements Ordered {
}
private static Set<String> initBasePackages(ControllerAdvice annotation) {
Set<String> basePackages = new LinkedHashSet<String>();
Set<String> basePackages = new LinkedHashSet<>();
for (String basePackage : annotation.basePackages()) {
if (StringUtils.hasText(basePackage)) {
basePackages.add(adaptBasePackage(basePackage));

View File

@@ -63,7 +63,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
private final BeanExpressionContext expressionContext;
private final Map<MethodParameter, NamedValueInfo> namedValueInfoCache = new ConcurrentHashMap<MethodParameter, NamedValueInfo>(256);
private final Map<MethodParameter, NamedValueInfo> namedValueInfoCache = new ConcurrentHashMap<>(256);
public AbstractNamedValueMethodArgumentResolver() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ public class ErrorsMethodArgumentResolver implements HandlerMethodArgumentResolv
ModelMap model = mavContainer.getModel();
if (model.size() > 0) {
int lastIndex = model.size()-1;
String lastKey = new ArrayList<String>(model.keySet()).get(lastIndex);
String lastKey = new ArrayList<>(model.keySet()).get(lastIndex);
if (lastKey.startsWith(BindingResult.MODEL_KEY_PREFIX)) {
return model.get(lastKey);
}

View File

@@ -60,10 +60,10 @@ public class ExceptionHandlerMethodResolver {
private final Map<Class<? extends Throwable>, Method> mappedMethods =
new ConcurrentHashMap<Class<? extends Throwable>, Method>(16);
new ConcurrentHashMap<>(16);
private final Map<Class<? extends Throwable>, Method> exceptionLookupCache =
new ConcurrentHashMap<Class<? extends Throwable>, Method>(16);
new ConcurrentHashMap<>(16);
/**
@@ -85,7 +85,7 @@ public class ExceptionHandlerMethodResolver {
*/
@SuppressWarnings("unchecked")
private List<Class<? extends Throwable>> detectExceptionMappings(Method method) {
List<Class<? extends Throwable>> result = new ArrayList<Class<? extends Throwable>>();
List<Class<? extends Throwable>> result = new ArrayList<>();
detectAnnotationExceptionMappings(method, result);
if (result.isEmpty()) {
for (Class<?> paramType : method.getParameterTypes()) {
@@ -154,7 +154,7 @@ public class ExceptionHandlerMethodResolver {
* Return the {@link Method} mapped to the given exception type, or {@code null} if none.
*/
private Method getMappedMethod(Class<? extends Throwable> exceptionType) {
List<Class<? extends Throwable>> matches = new ArrayList<Class<? extends Throwable>>();
List<Class<? extends Throwable>> matches = new ArrayList<>();
for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
if (mappedException.isAssignableFrom(exceptionType)) {
matches.add(mappedException);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ public class InitBinderDataBinderFactory extends DefaultDataBinderFactory {
*/
public InitBinderDataBinderFactory(List<InvocableHandlerMethod> binderMethods, WebBindingInitializer initializer) {
super(initializer);
this.binderMethods = (binderMethods != null) ? binderMethods : new ArrayList<InvocableHandlerMethod>();
this.binderMethods = (binderMethods != null) ? binderMethods : new ArrayList<>();
}
/**

View File

@@ -61,7 +61,7 @@ public final class ModelFactory {
private static final Log logger = LogFactory.getLog(ModelFactory.class);
private final List<ModelMethod> modelMethods = new ArrayList<ModelMethod>();
private final List<ModelMethod> modelMethods = new ArrayList<>();
private final WebDataBinderFactory dataBinderFactory;
@@ -172,7 +172,7 @@ public final class ModelFactory {
* Find {@code @ModelAttribute} arguments also listed as {@code @SessionAttributes}.
*/
private List<String> findSessionAttributeArguments(HandlerMethod handlerMethod) {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
for (MethodParameter parameter : handlerMethod.getMethodParameters()) {
if (parameter.hasParameterAnnotation(ModelAttribute.class)) {
String name = getNameForParameter(parameter);
@@ -247,7 +247,7 @@ public final class ModelFactory {
* Add {@link BindingResult} attributes to the model for attributes that require it.
*/
private void updateBindingResult(NativeWebRequest request, ModelMap model) throws Exception {
List<String> keyNames = new ArrayList<String>(model.keySet());
List<String> keyNames = new ArrayList<>(model.keySet());
for (String name : keyNames) {
Object value = model.get(name);
@@ -284,7 +284,7 @@ public final class ModelFactory {
private final InvocableHandlerMethod handlerMethod;
private final Set<String> dependencies = new HashSet<String>();
private final Set<String> dependencies = new HashSet<>();
private ModelMethod(InvocableHandlerMethod handlerMethod) {
this.handlerMethod = handlerMethod;
@@ -309,7 +309,7 @@ public final class ModelFactory {
}
public List<String> getUnresolvedDependencies(ModelAndViewContainer mavContainer) {
List<String> result = new ArrayList<String>(this.dependencies.size());
List<String> result = new ArrayList<>(this.dependencies.size());
for (String name : this.dependencies) {
if (!mavContainer.containsAttribute(name)) {
result.add(name);

View File

@@ -62,7 +62,7 @@ public class RequestHeaderMapMethodArgumentResolver implements HandlerMethodArgu
result = new HttpHeaders();
}
else {
result = new LinkedMultiValueMap<String, String>();
result = new LinkedMultiValueMap<>();
}
for (Iterator<String> iterator = webRequest.getHeaderNames(); iterator.hasNext();) {
String headerName = iterator.next();
@@ -76,7 +76,7 @@ public class RequestHeaderMapMethodArgumentResolver implements HandlerMethodArgu
return result;
}
else {
Map<String, String> result = new LinkedHashMap<String, String>();
Map<String, String> result = new LinkedHashMap<>();
for (Iterator<String> iterator = webRequest.getHeaderNames(); iterator.hasNext();) {
String headerName = iterator.next();
String headerValue = webRequest.getHeader(headerName);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@ public class RequestParamMapMethodArgumentResolver implements HandlerMethodArgum
Map<String, String[]> parameterMap = webRequest.getParameterMap();
if (MultiValueMap.class.isAssignableFrom(paramType)) {
MultiValueMap<String, String> result = new LinkedMultiValueMap<String, String>(parameterMap.size());
MultiValueMap<String, String> result = new LinkedMultiValueMap<>(parameterMap.size());
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
for (String value : entry.getValue()) {
result.add(entry.getKey(), value);
@@ -75,7 +75,7 @@ public class RequestParamMapMethodArgumentResolver implements HandlerMethodArgum
return result;
}
else {
Map<String, String> result = new LinkedHashMap<String, String>(parameterMap.size());
Map<String, String> result = new LinkedHashMap<>(parameterMap.size());
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
if (entry.getValue().length > 0) {
result.put(entry.getKey(), entry.getValue()[0]);

View File

@@ -47,9 +47,9 @@ import org.springframework.web.context.request.WebRequest;
*/
public class SessionAttributesHandler {
private final Set<String> attributeNames = new HashSet<String>();
private final Set<String> attributeNames = new HashSet<>();
private final Set<Class<?>> attributeTypes = new HashSet<Class<?>>();
private final Set<Class<?>> attributeTypes = new HashSet<>();
private final Set<String> knownAttributeNames =
Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(4));
@@ -135,7 +135,7 @@ public class SessionAttributesHandler {
* @return a map with handler session attributes, possibly empty
*/
public Map<String, Object> retrieveAttributes(WebRequest request) {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
for (String name : this.knownAttributeNames) {
Object value = this.sessionAttributeStore.retrieveAttribute(request, name);
if (value != null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ import org.springframework.web.util.UriComponentsBuilder;
*/
public class CompositeUriComponentsContributor implements UriComponentsContributor {
private final List<Object> contributors = new LinkedList<Object>();
private final List<Object> contributors = new LinkedList<>();
private final ConversionService conversionService;

View File

@@ -42,10 +42,10 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
protected final Log logger = LogFactory.getLog(getClass());
private final List<HandlerMethodArgumentResolver> argumentResolvers =
new LinkedList<HandlerMethodArgumentResolver>();
new LinkedList<>();
private final Map<MethodParameter, HandlerMethodArgumentResolver> argumentResolverCache =
new ConcurrentHashMap<MethodParameter, HandlerMethodArgumentResolver>(256);
new ConcurrentHashMap<>(256);
/**

View File

@@ -38,7 +38,7 @@ public class HandlerMethodReturnValueHandlerComposite implements AsyncHandlerMet
protected final Log logger = LogFactory.getLog(getClass());
private final List<HandlerMethodReturnValueHandler> returnValueHandlers =
new ArrayList<HandlerMethodReturnValueHandler>();
new ArrayList<>();
/**

View File

@@ -58,7 +58,7 @@ public class ModelAndViewContainer {
private boolean redirectModelScenario = false;
/* Names of attributes with binding disabled */
private final Set<String> bindingDisabledAttributes = new HashSet<String>(4);
private final Set<String> bindingDisabledAttributes = new HashSet<>(4);
private HttpStatus status;

View File

@@ -221,9 +221,9 @@ public abstract class CommonsFileUploadSupport {
* @see CommonsMultipartFile#CommonsMultipartFile(org.apache.commons.fileupload.FileItem)
*/
protected MultipartParsingResult parseFileItems(List<FileItem> fileItems, String encoding) {
MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>();
Map<String, String[]> multipartParameters = new HashMap<String, String[]>();
Map<String, String> multipartParameterContentTypes = new HashMap<String, String>();
MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<>();
Map<String, String[]> multipartParameters = new HashMap<>();
Map<String, String> multipartParameterContentTypes = new HashMap<>();
// Extract multipart files and multipart parameters.
for (FileItem fileItem : fileItems) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ public abstract class AbstractMultipartHttpServletRequest extends HttpServletReq
*/
protected final void setMultipartFiles(MultiValueMap<String, MultipartFile> multipartFiles) {
this.multipartFiles =
new LinkedMultiValueMap<String, MultipartFile>(Collections.unmodifiableMap(multipartFiles));
new LinkedMultiValueMap<>(Collections.unmodifiableMap(multipartFiles));
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -100,7 +100,7 @@ public class DefaultMultipartHttpServletRequest extends AbstractMultipartHttpSer
return super.getParameterNames();
}
Set<String> paramNames = new LinkedHashSet<String>();
Set<String> paramNames = new LinkedHashSet<>();
Enumeration<String> paramEnum = super.getParameterNames();
while (paramEnum.hasMoreElements()) {
paramNames.add(paramEnum.nextElement());
@@ -116,7 +116,7 @@ public class DefaultMultipartHttpServletRequest extends AbstractMultipartHttpSer
return super.getParameterMap();
}
Map<String, String[]> paramMap = new LinkedHashMap<String, String[]>();
Map<String, String[]> paramMap = new LinkedHashMap<>();
paramMap.putAll(super.getParameterMap());
paramMap.putAll(multipartParameters);
return paramMap;

View File

@@ -144,7 +144,7 @@ public abstract class MultipartResolutionDelegate {
private static List<Part> resolvePartList(HttpServletRequest servletRequest, String name) throws Exception {
Collection<Part> parts = servletRequest.getParts();
List<Part> result = new ArrayList<Part>(parts.size());
List<Part> result = new ArrayList<>(parts.size());
for (Part part : parts) {
if (part.getName().equals(name)) {
result.add(part);
@@ -155,7 +155,7 @@ public abstract class MultipartResolutionDelegate {
private static Part[] resolvePartArray(HttpServletRequest servletRequest, String name) throws Exception {
Collection<Part> parts = servletRequest.getParts();
List<Part> result = new ArrayList<Part>(parts.size());
List<Part> result = new ArrayList<>(parts.size());
for (Part part : parts) {
if (part.getName().equals(name)) {
result.add(part);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -90,8 +90,8 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
private void parseRequest(HttpServletRequest request) {
try {
Collection<Part> parts = request.getParts();
this.multipartParameterNames = new LinkedHashSet<String>(parts.size());
MultiValueMap<String, MultipartFile> files = new LinkedMultiValueMap<String, MultipartFile>(parts.size());
this.multipartParameterNames = new LinkedHashSet<>(parts.size());
MultiValueMap<String, MultipartFile> files = new LinkedMultiValueMap<>(parts.size());
for (Part part : parts) {
String disposition = part.getHeader(CONTENT_DISPOSITION);
String filename = extractFilename(disposition);
@@ -184,7 +184,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
// Servlet 3.0 getParameterNames() not guaranteed to include multipart form items
// (e.g. on WebLogic 12) -> need to merge them here to be on the safe side
Set<String> paramNames = new LinkedHashSet<String>();
Set<String> paramNames = new LinkedHashSet<>();
Enumeration<String> paramEnum = super.getParameterNames();
while (paramEnum.hasMoreElements()) {
paramNames.add(paramEnum.nextElement());
@@ -204,7 +204,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
// Servlet 3.0 getParameterMap() not guaranteed to include multipart form items
// (e.g. on WebLogic 12) -> need to merge them here to be on the safe side
Map<String, String[]> paramMap = new LinkedHashMap<String, String[]>();
Map<String, String[]> paramMap = new LinkedHashMap<>();
paramMap.putAll(super.getParameterMap());
for (String paramName : this.multipartParameterNames) {
if (!paramMap.containsKey(paramName)) {
@@ -232,7 +232,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
if (part != null) {
HttpHeaders headers = new HttpHeaders();
for (String headerName : part.getHeaderNames()) {
headers.put(headerName, new ArrayList<String>(part.getHeaders(headerName)));
headers.put(headerName, new ArrayList<>(part.getHeaders(headerName)));
}
return headers;
}

View File

@@ -38,7 +38,7 @@ public abstract class AbstractUriTemplateHandler implements UriTemplateHandler {
private String baseUrl;
private final Map<String, Object> defaultUriVariables = new HashMap<String, Object>();
private final Map<String, Object> defaultUriVariables = new HashMap<>();
/**
@@ -92,7 +92,7 @@ public abstract class AbstractUriTemplateHandler implements UriTemplateHandler {
@Override
public URI expand(String uriTemplate, Map<String, ?> uriVariables) {
if (!getDefaultUriVariables().isEmpty()) {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.putAll(getDefaultUriVariables());
map.putAll(uriVariables);
uriVariables = map;

View File

@@ -127,7 +127,7 @@ public class DefaultUriTemplateHandler extends AbstractUriTemplateHandler {
return builder.buildAndExpand(uriVariables).encode();
}
else {
Map<String, Object> encodedUriVars = new HashMap<String, Object>(uriVariables.size());
Map<String, Object> encodedUriVars = new HashMap<>(uriVariables.size());
for (Map.Entry<String, ?> entry : uriVariables.entrySet()) {
encodedUriVars.put(entry.getKey(), applyStrictEncoding(entry.getValue()));
}

View File

@@ -83,7 +83,7 @@ final class HierarchicalUriComponents extends UriComponents {
this.port = port;
this.path = path != null ? path : NULL_PATH_COMPONENT;
this.queryParams = CollectionUtils.unmodifiableMultiValueMap(
queryParams != null ? queryParams : new LinkedMultiValueMap<String, String>(0));
queryParams != null ? queryParams : new LinkedMultiValueMap<>(0));
this.encoded = encoded;
if (verify) {
verify();
@@ -200,10 +200,10 @@ final class HierarchicalUriComponents extends UriComponents {
private MultiValueMap<String, String> encodeQueryParams(String encoding) throws UnsupportedEncodingException {
int size = this.queryParams.size();
MultiValueMap<String, String> result = new LinkedMultiValueMap<String, String>(size);
MultiValueMap<String, String> result = new LinkedMultiValueMap<>(size);
for (Map.Entry<String, List<String>> entry : this.queryParams.entrySet()) {
String name = encodeUriComponent(entry.getKey(), encoding, Type.QUERY_PARAM);
List<String> values = new ArrayList<String>(entry.getValue().size());
List<String> values = new ArrayList<>(entry.getValue().size());
for (String value : entry.getValue()) {
values.add(encodeUriComponent(value, encoding, Type.QUERY_PARAM));
}
@@ -335,11 +335,11 @@ final class HierarchicalUriComponents extends UriComponents {
private MultiValueMap<String, String> expandQueryParams(UriTemplateVariables variables) {
int size = this.queryParams.size();
MultiValueMap<String, String> result = new LinkedMultiValueMap<String, String>(size);
MultiValueMap<String, String> result = new LinkedMultiValueMap<>(size);
variables = new QueryUriTemplateVariables(variables);
for (Map.Entry<String, List<String>> entry : this.queryParams.entrySet()) {
String name = expandUriComponent(entry.getKey(), variables);
List<String> values = new ArrayList<String>(entry.getValue().size());
List<String> values = new ArrayList<>(entry.getValue().size());
for (String value : entry.getValue()) {
values.add(expandUriComponent(value, variables));
}
@@ -714,7 +714,7 @@ final class HierarchicalUriComponents extends UriComponents {
public PathSegmentComponent(List<String> pathSegments) {
Assert.notNull(pathSegments);
this.pathSegments = Collections.unmodifiableList(new ArrayList<String>(pathSegments));
this.pathSegments = Collections.unmodifiableList(new ArrayList<>(pathSegments));
}
@Override
@@ -739,7 +739,7 @@ final class HierarchicalUriComponents extends UriComponents {
@Override
public PathComponent encode(String encoding) throws UnsupportedEncodingException {
List<String> pathSegments = getPathSegments();
List<String> encodedPathSegments = new ArrayList<String>(pathSegments.size());
List<String> encodedPathSegments = new ArrayList<>(pathSegments.size());
for (String pathSegment : pathSegments) {
String encodedPathSegment = encodeUriComponent(pathSegment, encoding, Type.PATH_SEGMENT);
encodedPathSegments.add(encodedPathSegment);
@@ -757,7 +757,7 @@ final class HierarchicalUriComponents extends UriComponents {
@Override
public PathComponent expand(UriTemplateVariables uriVariables) {
List<String> pathSegments = getPathSegments();
List<String> expandedPathSegments = new ArrayList<String>(pathSegments.size());
List<String> expandedPathSegments = new ArrayList<>(pathSegments.size());
for (String pathSegment : pathSegments) {
String expandedPathSegment = expandUriComponent(pathSegment, uriVariables);
expandedPathSegments.add(expandedPathSegment);
@@ -806,7 +806,7 @@ final class HierarchicalUriComponents extends UriComponents {
@Override
public List<String> getPathSegments() {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
for (PathComponent pathComponent : this.pathComponents) {
result.addAll(pathComponent.getPathSegments());
}
@@ -815,7 +815,7 @@ final class HierarchicalUriComponents extends UriComponents {
@Override
public PathComponent encode(String encoding) throws UnsupportedEncodingException {
List<PathComponent> encodedComponents = new ArrayList<PathComponent>(this.pathComponents.size());
List<PathComponent> encodedComponents = new ArrayList<>(this.pathComponents.size());
for (PathComponent pathComponent : this.pathComponents) {
encodedComponents.add(pathComponent.encode(encoding));
}
@@ -831,7 +831,7 @@ final class HierarchicalUriComponents extends UriComponents {
@Override
public PathComponent expand(UriTemplateVariables uriVariables) {
List<PathComponent> expandedComponents = new ArrayList<PathComponent>(this.pathComponents.size());
List<PathComponent> expandedComponents = new ArrayList<>(this.pathComponents.size());
for (PathComponent pathComponent : this.pathComponents) {
expandedComponents.add(pathComponent.expand(uriVariables));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ class HtmlCharacterEntityReferences {
private final String[] characterToEntityReferenceMap = new String[3000];
private final Map<String, Character> entityReferenceToCharacterMap = new HashMap<String, Character>(252);
private final Map<String, Character> entityReferenceToCharacterMap = new HashMap<>(252);
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ import org.springframework.util.ObjectUtils;
@SuppressWarnings("serial")
final class OpaqueUriComponents extends UriComponents {
private static final MultiValueMap<String, String> QUERY_PARAMS_NONE = new LinkedMultiValueMap<String, String>(0);
private static final MultiValueMap<String, String> QUERY_PARAMS_NONE = new LinkedMultiValueMap<>(0);
private final String ssp;

View File

@@ -106,7 +106,7 @@ public class UriComponentsBuilder implements Cloneable {
private CompositePathComponentBuilder pathBuilder;
private final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
private final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
private String fragment;
@@ -760,7 +760,7 @@ public class UriComponentsBuilder implements Cloneable {
private static class CompositePathComponentBuilder implements PathComponentBuilder {
private final LinkedList<PathComponentBuilder> builders = new LinkedList<PathComponentBuilder>();
private final LinkedList<PathComponentBuilder> builders = new LinkedList<>();
public CompositePathComponentBuilder() {
}
@@ -813,7 +813,7 @@ public class UriComponentsBuilder implements Cloneable {
@Override
public PathComponent build() {
int size = this.builders.size();
List<PathComponent> components = new ArrayList<PathComponent>(size);
List<PathComponent> components = new ArrayList<>(size);
for (PathComponentBuilder componentBuilder : this.builders) {
PathComponent pathComponent = componentBuilder.build();
if (pathComponent != null) {
@@ -882,7 +882,7 @@ public class UriComponentsBuilder implements Cloneable {
private static class PathSegmentComponentBuilder implements PathComponentBuilder {
private final List<String> pathSegments = new LinkedList<String>();
private final List<String> pathSegments = new LinkedList<>();
public void append(String... pathSegments) {
for (String pathSegment : pathSegments) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -146,7 +146,7 @@ public class UriTemplate implements Serializable {
*/
public Map<String, String> match(String uri) {
Assert.notNull(uri, "'uri' must not be null");
Map<String, String> result = new LinkedHashMap<String, String>(this.variableNames.size());
Map<String, String> result = new LinkedHashMap<>(this.variableNames.size());
Matcher matcher = this.matchPattern.matcher(uri);
if (matcher.find()) {
for (int i = 1; i <= matcher.groupCount(); i++) {
@@ -189,7 +189,7 @@ public class UriTemplate implements Serializable {
private static TemplateInfo parse(String uriTemplate) {
int level = 0;
List<String> variableNames = new ArrayList<String>();
List<String> variableNames = new ArrayList<>();
StringBuilder pattern = new StringBuilder();
StringBuilder builder = new StringBuilder();
for (int i = 0 ; i < uriTemplate.length(); i++) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -526,7 +526,7 @@ public class UrlPathHelper {
return vars;
}
else {
Map<String, String> decodedVars = new LinkedHashMap<String, String>(vars.size());
Map<String, String> decodedVars = new LinkedHashMap<>(vars.size());
for (Entry<String, String> entry : vars.entrySet()) {
decodedVars.put(entry.getKey(), decodeInternal(request, entry.getValue()));
}
@@ -550,7 +550,7 @@ public class UrlPathHelper {
return vars;
}
else {
MultiValueMap<String, String> decodedVars = new LinkedMultiValueMap <String, String>(vars.size());
MultiValueMap<String, String> decodedVars = new LinkedMultiValueMap<>(vars.size());
for (String key : vars.keySet()) {
for (String value : vars.get(key)) {
decodedVars.add(key, decodeInternal(request, value));

View File

@@ -641,7 +641,7 @@ public abstract class WebUtils {
public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) {
Assert.notNull(request, "Request must not be null");
Enumeration<String> paramNames = request.getParameterNames();
Map<String, Object> params = new TreeMap<String, Object>();
Map<String, Object> params = new TreeMap<>();
if (prefix == null) {
prefix = "";
}
@@ -737,7 +737,7 @@ public abstract class WebUtils {
* @since 3.2
*/
public static MultiValueMap<String, String> parseMatrixVariables(String matrixVariables) {
MultiValueMap<String, String> result = new LinkedMultiValueMap<String, String>();
MultiValueMap<String, String> result = new LinkedMultiValueMap<>();
if (!StringUtils.hasText(matrixVariables)) {
return result;
}