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

@@ -54,7 +54,7 @@ import org.springframework.util.ObjectUtils;
*/
public class CaffeineCacheManager implements CacheManager {
private final ConcurrentMap<String, Cache> cacheMap = new ConcurrentHashMap<String, Cache>(16);
private final ConcurrentMap<String, Cache> cacheMap = new ConcurrentHashMap<>(16);
private boolean dynamic = true;

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,7 +86,7 @@ public class EhCacheCacheManager extends AbstractTransactionSupportingCacheManag
}
String[] names = getCacheManager().getCacheNames();
Collection<Cache> caches = new LinkedHashSet<Cache>(names.length);
Collection<Cache> caches = new LinkedHashSet<>(names.length);
for (String name : names) {
caches.add(new EhCacheCache(getCacheManager().getEhcache(name)));
}

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 @@ import org.springframework.util.ObjectUtils;
*/
public class GuavaCacheManager implements CacheManager {
private final ConcurrentMap<String, Cache> cacheMap = new ConcurrentHashMap<String, Cache>(16);
private final ConcurrentMap<String, Cache> cacheMap = new ConcurrentHashMap<>(16);
private boolean dynamic = true;

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 JCacheCacheManager extends AbstractTransactionSupportingCacheManage
@Override
protected Collection<Cache> loadCaches() {
Collection<Cache> caches = new LinkedHashSet<Cache>();
Collection<Cache> caches = new LinkedHashSet<>();
for (String cacheName : getCacheManager().getCacheNames()) {
javax.cache.Cache<Object, Object> jcache = getCacheManager().getCache(cacheName);
caches.add(new JCacheCache(jcache, isAllowNullValues()));

View File

@@ -51,7 +51,7 @@ public abstract class AbstractFallbackJCacheOperationSource implements JCacheOpe
protected final Log logger = LogFactory.getLog(getClass());
private final Map<MethodClassKey, Object> cache = new ConcurrentHashMap<MethodClassKey, Object>(1024);
private final Map<MethodClassKey, Object> cache = new ConcurrentHashMap<>(1024);
@Override

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.
@@ -73,7 +73,7 @@ abstract class AbstractJCacheKeyOperation<A extends Annotation> extends Abstract
* used to compute the key
*/
public CacheInvocationParameter[] getKeyParameters(Object... values) {
List<CacheInvocationParameter> result = new ArrayList<CacheInvocationParameter>();
List<CacheInvocationParameter> result = new ArrayList<>();
for (CacheParameterDetail keyParameterDetail : this.keyParameterDetails) {
int parameterPosition = keyParameterDetail.getParameterPosition();
if (parameterPosition >= values.length) {
@@ -87,8 +87,8 @@ abstract class AbstractJCacheKeyOperation<A extends Annotation> extends Abstract
private static List<CacheParameterDetail> initializeKeyParameterDetails(List<CacheParameterDetail> allParameters) {
List<CacheParameterDetail> all = new ArrayList<CacheParameterDetail>();
List<CacheParameterDetail> annotated = new ArrayList<CacheParameterDetail>();
List<CacheParameterDetail> all = new ArrayList<>();
List<CacheParameterDetail> annotated = new ArrayList<>();
for (CacheParameterDetail allParameter : allParameters) {
if (!allParameter.isValue()) {
all.add(allParameter);

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.
@@ -106,7 +106,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
throw new IllegalStateException("Values mismatch, operation has " +
this.allParameterDetails.size() + " parameter(s) but got " + values.length + " value(s)");
}
List<CacheInvocationParameter> result = new ArrayList<CacheInvocationParameter>();
List<CacheInvocationParameter> result = new ArrayList<>();
for (int i = 0; i < this.allParameterDetails.size(); i++) {
result.add(this.allParameterDetails.get(i).toCacheInvocationParameter(values[i]));
}
@@ -138,7 +138,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
List<CacheParameterDetail> result = new ArrayList<CacheParameterDetail>();
List<CacheParameterDetail> result = new ArrayList<>();
for (int i = 0; i < method.getParameterTypes().length; i++) {
CacheParameterDetail detail = new CacheParameterDetail(method, i);
result.add(detail);
@@ -161,7 +161,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
public CacheParameterDetail(Method method, int parameterPosition) {
this.rawType = method.getParameterTypes()[parameterPosition];
this.annotations = new LinkedHashSet<Annotation>();
this.annotations = new LinkedHashSet<>();
boolean foundKeyAnnotation = false;
boolean foundValueAnnotation = false;
for (Annotation annotation : method.getParameterAnnotations()[parameterPosition]) {

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.
@@ -58,7 +58,7 @@ abstract class AbstractKeyCacheInterceptor<O extends AbstractJCacheKeyOperation<
*/
protected CacheKeyInvocationContext<A> createCacheKeyInvocationContext(
CacheOperationInvocationContext<O> context) {
return new DefaultCacheKeyInvocationContext<A>(context.getOperation(), context.getTarget(), context.getArgs());
return new DefaultCacheKeyInvocationContext<>(context.getOperation(), context.getTarget(), context.getArgs());
}
}

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.
@@ -132,7 +132,7 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC
}
private <A extends Annotation> CacheMethodDetails<A> createMethodDetails(Method method, A annotation, String cacheName) {
return new DefaultCacheMethodDetails<A>(method, annotation, cacheName);
return new DefaultCacheMethodDetails<>(method, annotation, cacheName);
}
protected CacheResolver getCacheResolver(CacheResolverFactory factory, CacheMethodDetails<?> details) {
@@ -200,7 +200,7 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC
*/
protected String generateDefaultCacheName(Method method) {
Class<?>[] parameterTypes = method.getParameterTypes();
List<String> parameters = new ArrayList<String>(parameterTypes.length);
List<String> parameters = new ArrayList<>(parameterTypes.length);
for (Class<?> parameterType : parameterTypes) {
parameters.add(parameterType.getName());
}

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.
@@ -45,7 +45,7 @@ class DefaultCacheMethodDetails<A extends Annotation> implements CacheMethodDeta
public DefaultCacheMethodDetails(Method method, A cacheAnnotation, String cacheName) {
this.method = method;
this.annotations = Collections.unmodifiableSet(
new LinkedHashSet<Annotation>(asList(method.getAnnotations())));
new LinkedHashSet<>(asList(method.getAnnotations())));
this.cacheAnnotation = cacheAnnotation;
this.cacheName = cacheName;
}

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.
@@ -110,7 +110,7 @@ public class JCacheAspectSupport extends AbstractCacheInvoker implements Initial
private CacheOperationInvocationContext<?> createCacheOperationInvocationContext(
Object target, Object[] args, JCacheOperation<?> operation) {
return new DefaultCacheInvocationContext<Annotation>(
return new DefaultCacheInvocationContext<>(
(JCacheOperation<Annotation>) operation, target, args);
}

View File

@@ -1,3 +1,19 @@
/*
* 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.
* You may obtain a copy of the License at
*
* 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,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cache.jcache.interceptor;
import java.lang.annotation.Annotation;
@@ -77,7 +93,7 @@ class KeyGeneratorAdapter implements KeyGenerator {
@SuppressWarnings("unchecked")
private static Object doGenerate(KeyGenerator keyGenerator, CacheKeyInvocationContext<?> context) {
List<Object> parameters = new ArrayList<Object>();
List<Object> parameters = new ArrayList<>();
for (CacheInvocationParameter param : context.getKeyParameters()) {
Object value = param.getValue();
if (param.getParameterPosition() == context.getAllParameters().length - 1 &&
@@ -98,7 +114,7 @@ class KeyGeneratorAdapter implements KeyGenerator {
private CacheKeyInvocationContext<?> createCacheKeyInvocationContext(Object target,
JCacheOperation<?> operation, Object[] params) {
AbstractJCacheKeyOperation<Annotation> keyCacheOperation = (AbstractJCacheKeyOperation<Annotation>) operation;
return new DefaultCacheKeyInvocationContext<Annotation>(keyCacheOperation, target, params);
return new DefaultCacheKeyInvocationContext<>(keyCacheOperation, target, params);
}
}

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.
@@ -53,7 +53,7 @@ public class MailSendException extends MailException {
*/
public MailSendException(String msg, Throwable cause) {
super(msg, cause);
this.failedMessages = new LinkedHashMap<Object, Exception>();
this.failedMessages = new LinkedHashMap<>();
}
/**
@@ -68,7 +68,7 @@ public class MailSendException extends MailException {
*/
public MailSendException(String msg, Throwable cause, Map<Object, Exception> failedMessages) {
super(msg, cause);
this.failedMessages = new LinkedHashMap<Object, Exception>(failedMessages);
this.failedMessages = new LinkedHashMap<>(failedMessages);
this.messageExceptions = failedMessages.values().toArray(new Exception[failedMessages.size()]);
}

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.
@@ -298,7 +298,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
@Override
public void send(SimpleMailMessage... simpleMessages) throws MailException {
List<MimeMessage> mimeMessages = new ArrayList<MimeMessage>(simpleMessages.length);
List<MimeMessage> mimeMessages = new ArrayList<>(simpleMessages.length);
for (SimpleMailMessage simpleMessage : simpleMessages) {
MimeMailMessage message = new MimeMailMessage(createMimeMessage());
simpleMessage.copyTo(message);
@@ -353,7 +353,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
@Override
public void send(MimeMessagePreparator... mimeMessagePreparators) throws MailException {
try {
List<MimeMessage> mimeMessages = new ArrayList<MimeMessage>(mimeMessagePreparators.length);
List<MimeMessage> mimeMessages = new ArrayList<>(mimeMessagePreparators.length);
for (MimeMessagePreparator preparator : mimeMessagePreparators) {
MimeMessage mimeMessage = createMimeMessage();
preparator.prepare(mimeMessage);
@@ -400,7 +400,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
* in case of failure when sending a message
*/
protected void doSend(MimeMessage[] mimeMessages, Object[] originalMessages) throws MailException {
Map<Object, Exception> failedMessages = new LinkedHashMap<Object, Exception>();
Map<Object, Exception> failedMessages = new LinkedHashMap<>();
Transport transport = null;
try {

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.
@@ -56,7 +56,7 @@ public class TimerManagerFactoryBean extends TimerManagerAccessor
private ScheduledTimerListener[] scheduledTimerListeners;
private final List<Timer> timers = new LinkedList<Timer>();
private final List<Timer> timers = new LinkedList<>();
/**

View File

@@ -160,28 +160,28 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
@Override
public Future<?> submit(Runnable task) {
FutureTask<Object> future = new FutureTask<Object>(task, null);
FutureTask<Object> future = new FutureTask<>(task, null);
execute(future);
return future;
}
@Override
public <T> Future<T> submit(Callable<T> task) {
FutureTask<T> future = new FutureTask<T>(task);
FutureTask<T> future = new FutureTask<>(task);
execute(future);
return future;
}
@Override
public ListenableFuture<?> submitListenable(Runnable task) {
ListenableFutureTask<Object> future = new ListenableFutureTask<Object>(task, null);
ListenableFutureTask<Object> future = new ListenableFutureTask<>(task, null);
execute(future);
return future;
}
@Override
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
ListenableFutureTask<T> future = new ListenableFutureTask<T>(task);
ListenableFutureTask<T> future = new ListenableFutureTask<>(task);
execute(future);
return future;
}

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.
@@ -125,7 +125,7 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware {
public void setJobDetails(JobDetail... jobDetails) {
// Use modifiable ArrayList here, to allow for further adding of
// JobDetail objects during autodetection of JobDetail-aware Triggers.
this.jobDetails = new ArrayList<JobDetail>(Arrays.asList(jobDetails));
this.jobDetails = new ArrayList<>(Arrays.asList(jobDetails));
}
/**
@@ -218,7 +218,7 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware {
}
else {
// Create empty list for easier checks when registering triggers.
this.jobDetails = new LinkedList<JobDetail>();
this.jobDetails = new LinkedList<>();
}
// Register Calendars.

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.
@@ -94,16 +94,16 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
private static final ThreadLocal<ResourceLoader> configTimeResourceLoaderHolder =
new ThreadLocal<ResourceLoader>();
new ThreadLocal<>();
private static final ThreadLocal<Executor> configTimeTaskExecutorHolder =
new ThreadLocal<Executor>();
new ThreadLocal<>();
private static final ThreadLocal<DataSource> configTimeDataSourceHolder =
new ThreadLocal<DataSource>();
new ThreadLocal<>();
private static final ThreadLocal<DataSource> configTimeNonTransactionalDataSourceHolder =
new ThreadLocal<DataSource>();
new ThreadLocal<>();
/**
* Return the ResourceLoader for the currently configured Quartz Scheduler,

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -83,28 +83,28 @@ public class SimpleThreadPoolTaskExecutor extends SimpleThreadPool
@Override
public Future<?> submit(Runnable task) {
FutureTask<Object> future = new FutureTask<Object>(task, null);
FutureTask<Object> future = new FutureTask<>(task, null);
execute(future);
return future;
}
@Override
public <T> Future<T> submit(Callable<T> task) {
FutureTask<T> future = new FutureTask<T>(task);
FutureTask<T> future = new FutureTask<>(task);
execute(future);
return future;
}
@Override
public ListenableFuture<?> submitListenable(Runnable task) {
ListenableFutureTask<Object> future = new ListenableFutureTask<Object>(task, null);
ListenableFutureTask<Object> future = new ListenableFutureTask<>(task, null);
execute(future);
return future;
}
@Override
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
ListenableFutureTask<T> future = new ListenableFutureTask<T>(task);
ListenableFutureTask<T> future = new ListenableFutureTask<>(task);
execute(future);
return future;
}

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.
@@ -85,7 +85,7 @@ public class FreeMarkerConfigurationFactory {
private String defaultEncoding;
private final List<TemplateLoader> templateLoaders = new ArrayList<TemplateLoader>();
private final List<TemplateLoader> templateLoaders = new ArrayList<>();
private List<TemplateLoader> preTemplateLoaders;
@@ -277,7 +277,7 @@ public class FreeMarkerConfigurationFactory {
config.setDefaultEncoding(this.defaultEncoding);
}
List<TemplateLoader> templateLoaders = new LinkedList<TemplateLoader>(this.templateLoaders);
List<TemplateLoader> templateLoaders = new LinkedList<>(this.templateLoaders);
// Register template loaders that are supposed to kick in early.
if (this.preTemplateLoaders != null) {