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.
@@ -107,7 +107,7 @@ public class MessageHeadersTests {
@Test
public void testNonTypedAccessOfHeaderValue() {
Integer value = new Integer(123);
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("test", value);
MessageHeaders headers = new MessageHeaders(map);
assertEquals(value, headers.get("test"));
@@ -116,7 +116,7 @@ public class MessageHeadersTests {
@Test
public void testTypedAccessOfHeaderValue() {
Integer value = new Integer(123);
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("test", value);
MessageHeaders headers = new MessageHeaders(map);
assertEquals(value, headers.get("test", Integer.class));
@@ -125,7 +125,7 @@ public class MessageHeadersTests {
@Test(expected = IllegalArgumentException.class)
public void testHeaderValueAccessWithIncorrectType() {
Integer value = new Integer(123);
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("test", value);
MessageHeaders headers = new MessageHeaders(map);
assertEquals(value, headers.get("test", String.class));
@@ -133,21 +133,21 @@ public class MessageHeadersTests {
@Test
public void testNullHeaderValue() {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
MessageHeaders headers = new MessageHeaders(map);
assertNull(headers.get("nosuchattribute"));
}
@Test
public void testNullHeaderValueWithTypedAccess() {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
MessageHeaders headers = new MessageHeaders(map);
assertNull(headers.get("nosuchattribute", String.class));
}
@Test
public void testHeaderKeys() {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("key1", "val1");
map.put("key2", new Integer(123));
MessageHeaders headers = new MessageHeaders(map);
@@ -158,7 +158,7 @@ public class MessageHeadersTests {
@Test
public void serializeWithAllSerializableHeaders() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("name", "joe");
map.put("age", 42);
MessageHeaders input = new MessageHeaders(map);
@@ -172,7 +172,7 @@ public class MessageHeadersTests {
@Test
public void serializeWithNonSerializableHeader() throws Exception {
Object address = new Object();
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("name", "joe");
map.put("address", address);
MessageHeaders input = new MessageHeaders(map);

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.
@@ -46,7 +46,7 @@ public class DefaultContentTypeResolverTests {
@Test
public void resolve() {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON);
MessageHeaders headers = new MessageHeaders(map);
@@ -55,7 +55,7 @@ public class DefaultContentTypeResolverTests {
@Test
public void resolveStringContentType() {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON_VALUE);
MessageHeaders headers = new MessageHeaders(map);
@@ -64,7 +64,7 @@ public class DefaultContentTypeResolverTests {
@Test(expected = InvalidMimeTypeException.class)
public void resolveInvalidStringContentType() {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put(MessageHeaders.CONTENT_TYPE, "invalidContentType");
MessageHeaders headers = new MessageHeaders(map);
this.resolver.resolve(headers);
@@ -72,7 +72,7 @@ public class DefaultContentTypeResolverTests {
@Test(expected = IllegalArgumentException.class)
public void resolveUnknownHeaderType() {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put(MessageHeaders.CONTENT_TYPE, new Integer(1));
MessageHeaders headers = new MessageHeaders(map);
this.resolver.resolve(headers);

View File

@@ -106,7 +106,7 @@ public class MessageConverterTests {
@Test
public void toMessageWithHeaders() {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("foo", "bar");
MessageHeaders headers = new MessageHeaders(map);
Message<?> message = this.converter.toMessage("ABC", headers);

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.
@@ -101,7 +101,7 @@ public class StringMessageConverterTests {
@Test
public void toMessage() {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN);
MessageHeaders headers = new MessageHeaders(map);
Message<?> message = this.converter.toMessage("ABC", headers);

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.
@@ -33,7 +33,7 @@ public class CachingDestinationResolverTests {
public void cachedDestination() {
@SuppressWarnings("unchecked")
DestinationResolver<String> destinationResolver = mock(DestinationResolver.class);
CachingDestinationResolverProxy<String> cachingDestinationResolver = new CachingDestinationResolverProxy<String>(destinationResolver);
CachingDestinationResolverProxy<String> cachingDestinationResolver = new CachingDestinationResolverProxy<>(destinationResolver);
given(destinationResolver.resolveDestination("abcd")).willReturn("dcba");
given(destinationResolver.resolveDestination("1234")).willReturn("4321");
@@ -49,7 +49,7 @@ public class CachingDestinationResolverTests {
@Test(expected = IllegalArgumentException.class)
public void noTargetSet() {
CachingDestinationResolverProxy<String> cachingDestinationResolver = new CachingDestinationResolverProxy<String>();
CachingDestinationResolverProxy<String> cachingDestinationResolver = new CachingDestinationResolverProxy<>();
cachingDestinationResolver.afterPropertiesSet();
}

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.
@@ -72,7 +72,7 @@ public class GenericMessagingTemplateTests {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
replyChannel.send(new GenericMessage<String>("response"));
replyChannel.send(new GenericMessage<>("response"));
}
});
@@ -83,7 +83,7 @@ public class GenericMessagingTemplateTests {
@Test
public void sendAndReceiveTimeout() throws InterruptedException {
final AtomicReference<Throwable> failure = new AtomicReference<Throwable>();
final AtomicReference<Throwable> failure = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
this.template.setReceiveTimeout(1);
@@ -96,7 +96,7 @@ public class GenericMessagingTemplateTests {
try {
Thread.sleep(500);
MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
replyChannel.send(new GenericMessage<String>("response"));
replyChannel.send(new GenericMessage<>("response"));
failure.set(new IllegalStateException("Expected exception"));
}
catch (InterruptedException e) {

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.
@@ -114,7 +114,7 @@ public class DefaultMessageHandlerMethodFactoryTests {
@Test
public void customArgumentResolver() throws Exception {
DefaultMessageHandlerMethodFactory instance = createInstance();
List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<HandlerMethodArgumentResolver>();
List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<>();
customResolvers.add(new CustomHandlerMethodArgumentResolver());
instance.setCustomArgumentResolvers(customResolvers);
instance.afterPropertiesSet();
@@ -129,7 +129,7 @@ public class DefaultMessageHandlerMethodFactoryTests {
@Test
public void overrideArgumentResolvers() throws Exception {
DefaultMessageHandlerMethodFactory instance = createInstance();
List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<HandlerMethodArgumentResolver>();
List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<>();
customResolvers.add(new CustomHandlerMethodArgumentResolver());
instance.setArgumentResolvers(customResolvers);
instance.afterPropertiesSet();
@@ -211,7 +211,7 @@ public class DefaultMessageHandlerMethodFactoryTests {
static class SampleBean {
private final Map<String, Boolean> invocations = new HashMap<String, Boolean>();
private final Map<String, Boolean> invocations = new HashMap<>();
public void simpleString(String value) {
invocations.put("simpleString", true);

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.
@@ -73,7 +73,7 @@ public class DestinationVariableMethodArgumentResolverTests {
@Test
public void resolveArgument() throws Exception {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> vars = new HashMap<>();
vars.put("foo", "bar");
vars.put("name", "value");

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.
@@ -65,7 +65,7 @@ public class HeadersMethodArgumentResolverTests {
this.paramMessageHeaderAccessor = new MethodParameter(method, 3);
this.paramMessageHeaderAccessorSubclass = new MethodParameter(method, 4);
Map<String, Object> headers = new HashMap<String, Object>();
Map<String, Object> headers = new HashMap<>();
headers.put("foo", "bar");
this.message = MessageBuilder.withPayload(new byte[0]).copyHeaders(headers).build();
}

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.
@@ -142,7 +142,7 @@ public class MethodMessageHandlerTests {
public String method;
private Map<String, Object> arguments = new LinkedHashMap<String, Object>();
private Map<String, Object> arguments = new LinkedHashMap<>();
public void handlerPathMatchWildcard() {
this.method = "pathMatchWildcard";
@@ -196,7 +196,7 @@ public class MethodMessageHandlerTests {
@Override
protected List<? extends HandlerMethodArgumentResolver> initArgumentResolvers() {
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<HandlerMethodArgumentResolver>();
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
resolvers.add(new MessageMethodArgumentResolver(new SimpleMessageConverter()));
resolvers.addAll(getCustomArgumentResolvers());
return resolvers;
@@ -204,7 +204,7 @@ public class MethodMessageHandlerTests {
@Override
protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers() {
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<HandlerMethodReturnValueHandler>();
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>();
handlers.addAll(getCustomReturnValueHandlers());
return handlers;
}
@@ -225,7 +225,7 @@ public class MethodMessageHandlerTests {
@Override
protected Set<String> getDirectLookupDestinations(String mapping) {
Set<String> result = new LinkedHashSet<String>();
Set<String> result = new LinkedHashSet<>();
if (!this.pathMatcher.isPattern(mapping)) {
result.add(mapping);
}
@@ -273,7 +273,7 @@ public class MethodMessageHandlerTests {
}
private static Map<Class<? extends Throwable>, Method> initExceptionMappings(Class<?> handlerType) {
Map<Class<? extends Throwable>, Method> result = new HashMap<Class<? extends Throwable>, Method>();
Map<Class<? extends Throwable>, Method> result = new HashMap<>();
for (Method method : MethodIntrospector.selectMethods(handlerType, EXCEPTION_HANDLER_METHOD_FILTER)) {
for (Class<? extends Throwable> exception : getExceptionsFromMethodSignature(method)) {
result.put(exception, method);

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.
@@ -367,7 +367,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
private String method;
private Map<String, Object> arguments = new LinkedHashMap<String, Object>();
private Map<String, Object> arguments = new LinkedHashMap<>();
@MessageMapping("/headers")
public void headers(@Header String foo, @Headers Map<String, Object> headers) {
@@ -462,13 +462,13 @@ public class SimpAnnotationMethodMessageHandlerTests {
@MessageMapping("success")
public ListenableFutureTask<String> handleListenableFuture() {
this.future = new ListenableFutureTask<String>(() -> "foo");
this.future = new ListenableFutureTask<>(() -> "foo");
return this.future;
}
@MessageMapping("failure")
public ListenableFutureTask<String> handleListenableFutureException() {
this.future = new ListenableFutureTask<String>(() -> {
this.future = new ListenableFutureTask<>(() -> {
throw new IllegalStateException();
});
return this.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.
@@ -285,7 +285,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
public void expectMessages(MessageExchange... messageExchanges) throws InterruptedException {
List<MessageExchange> expectedMessages =
new ArrayList<MessageExchange>(Arrays.<MessageExchange>asList(messageExchanges));
new ArrayList<>(Arrays.<MessageExchange>asList(messageExchanges));
while (expectedMessages.size() > 0) {
Message<?> message = this.queue.poll(10000, TimeUnit.MILLISECONDS);

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.
@@ -39,7 +39,7 @@ import static org.junit.Assert.*;
*/
public class StompCodecTests {
private final ArgumentCapturingConsumer<Message<byte[]>> consumer = new ArgumentCapturingConsumer<Message<byte[]>>();
private final ArgumentCapturingConsumer<Message<byte[]>> consumer = new ArgumentCapturingConsumer<>();
private final Function<Buffer, Message<byte[]>> decoder = new Reactor2StompCodec().decoder(consumer);
@@ -175,7 +175,7 @@ public class StompCodecTests {
Buffer buffer = Buffer.wrap(frame1 + frame2);
final List<Message<byte[]>> messages = new ArrayList<Message<byte[]>>();
final List<Message<byte[]>> messages = new ArrayList<>();
new Reactor2StompCodec().decoder(messages::add).apply(buffer);
assertEquals(2, messages.size());
@@ -247,7 +247,7 @@ public class StompCodecTests {
Buffer buffer = Buffer.wrap(frame);
final List<Message<byte[]>> messages = new ArrayList<Message<byte[]>>();
final List<Message<byte[]>> messages = new ArrayList<>();
new Reactor2StompCodec().decoder(messages::add).apply(buffer);
assertEquals(1, messages.size());
@@ -335,7 +335,7 @@ public class StompCodecTests {
private static final class ArgumentCapturingConsumer<T> implements Consumer<T> {
private final List<T> arguments = new ArrayList<T>();
private final List<T> arguments = new ArrayList<>();
@Override
public void accept(T t) {

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 @@ public class StompHeaderAccessorTests {
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.CONNECTED);
assertEquals(StompCommand.CONNECTED, accessor.getCommand());
accessor = StompHeaderAccessor.create(StompCommand.CONNECTED, new LinkedMultiValueMap<String, String>());
accessor = StompHeaderAccessor.create(StompCommand.CONNECTED, new LinkedMultiValueMap<>());
assertEquals(StompCommand.CONNECTED, accessor.getCommand());
}

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.
@@ -186,7 +186,7 @@ public class ChannelInterceptorTests {
private static class TestMessageHandler implements MessageHandler {
private final List<Message<?>> messages = new ArrayList<Message<?>>();
private final List<Message<?>> messages = new ArrayList<>();
public List<Message<?>> getMessages() {
return this.messages;

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.
@@ -64,7 +64,7 @@ public class NativeMessageHeaderAccessorTests {
inputNativeHeaders.add("foo", "bar");
inputNativeHeaders.add("bar", "baz");
Map<String, Object> inputHeaders = new HashMap<String, Object>();
Map<String, Object> inputHeaders = new HashMap<>();
inputHeaders.put("a", "b");
inputHeaders.put(NativeMessageHeaderAccessor.NATIVE_HEADERS, inputNativeHeaders);
@@ -97,7 +97,7 @@ public class NativeMessageHeaderAccessorTests {
inputNativeHeaders.add("foo", "bar");
inputNativeHeaders.add("bar", "baz");
Map<String, Object> nativeHeaders = new HashMap<String, Object>();
Map<String, Object> nativeHeaders = new HashMap<>();
nativeHeaders.put("a", "b");
nativeHeaders.put(NativeMessageHeaderAccessor.NATIVE_HEADERS, inputNativeHeaders);