Spring cleaning: use diamond operator
This commit is contained in:
@@ -89,7 +89,7 @@ public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implement
|
||||
proxyDefinition.setDecoratedDefinition(targetHolder);
|
||||
proxyDefinition.getPropertyValues().add("target", targetHolder);
|
||||
// create the interceptor names list
|
||||
proxyDefinition.getPropertyValues().add("interceptorNames", new ManagedList<String>());
|
||||
proxyDefinition.getPropertyValues().add("interceptorNames", new ManagedList<>());
|
||||
// copy autowire settings from original bean definition.
|
||||
proxyDefinition.setAutowireCandidate(targetDefinition.isAutowireCandidate());
|
||||
proxyDefinition.setPrimary(targetDefinition.isPrimary());
|
||||
|
||||
@@ -144,7 +144,7 @@ class BeanWrapperGenericsTests {
|
||||
@Test
|
||||
void testGenericMapElementWithKeyType() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
gb.setLongMap(new HashMap<Long, Integer>());
|
||||
gb.setLongMap(new HashMap<>());
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("longMap[4]", "5");
|
||||
assertThat(gb.getLongMap().get(Long.valueOf("4"))).isEqualTo("5");
|
||||
|
||||
@@ -154,7 +154,7 @@ class CollectionFactoryTests {
|
||||
|
||||
@Test
|
||||
void createApproximateCollectionFromEmptyHashSet() {
|
||||
Collection<String> set = createApproximateCollection(new HashSet<String>(), 2);
|
||||
Collection<String> set = createApproximateCollection(new HashSet<>(), 2);
|
||||
assertThat(set).isEmpty();
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ class CollectionFactoryTests {
|
||||
|
||||
@Test
|
||||
void createApproximateMapFromEmptyHashMap() {
|
||||
Map<String, String> map = createApproximateMap(new HashMap<String, String>(), 2);
|
||||
Map<String, String> map = createApproximateMap(new HashMap<>(), 2);
|
||||
assertThat(map).isEmpty();
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ class CollectionFactoryTests {
|
||||
|
||||
@Test
|
||||
void createApproximateMapFromEmptyEnumMap() {
|
||||
Map<Color, String> colors = createApproximateMap(new EnumMap<Color, String>(Color.class), 2);
|
||||
Map<Color, String> colors = createApproximateMap(new EnumMap<>(Color.class), 2);
|
||||
assertThat(colors).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ class ResolvableTypeTests {
|
||||
|
||||
@Test
|
||||
void forInstanceProviderNull() {
|
||||
ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType<String>(null));
|
||||
ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType<>(null));
|
||||
assertThat(type.getType()).isEqualTo(MyGenericInterfaceType.class);
|
||||
assertThat(type.resolve()).isEqualTo(MyGenericInterfaceType.class);
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ class GenericConversionServiceTests {
|
||||
void enumWithInterfaceToStringConversion() {
|
||||
// SPR-9692
|
||||
conversionService.addConverter(new EnumToStringConverter(conversionService));
|
||||
conversionService.addConverter(new MyEnumInterfaceToStringConverter<MyEnum>());
|
||||
conversionService.addConverter(new MyEnumInterfaceToStringConverter<>());
|
||||
assertThat(conversionService.convert(MyEnum.A, String.class)).isEqualTo("1");
|
||||
}
|
||||
|
||||
|
||||
@@ -423,9 +423,9 @@ class AnnotationMetadataTests {
|
||||
assertThat(method.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value")).isEqualTo("direct");
|
||||
assertThat(method.getAnnotationAttributes(DirectAnnotation.class.getName()).get("myValue")).isEqualTo("direct");
|
||||
List<Object> allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
|
||||
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(Arrays.asList("direct", "meta")));
|
||||
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<>(Arrays.asList("direct", "meta")));
|
||||
allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("additional");
|
||||
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(List.of("direct")));
|
||||
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<>(List.of("direct")));
|
||||
|
||||
assertThat(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName())).isTrue();
|
||||
|
||||
@@ -465,9 +465,9 @@ class AnnotationMetadataTests {
|
||||
|
||||
assertThat(metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value")).isEqualTo("direct");
|
||||
allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
|
||||
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(Arrays.asList("direct", "meta")));
|
||||
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<>(Arrays.asList("direct", "meta")));
|
||||
allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("additional");
|
||||
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(Arrays.asList("direct", "")));
|
||||
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<>(Arrays.asList("direct", "")));
|
||||
assertThat(metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("additional")).isEqualTo("");
|
||||
assertThat(((String[]) metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("additionalArray"))).isEmpty();
|
||||
}
|
||||
@@ -498,7 +498,7 @@ class AnnotationMetadataTests {
|
||||
|
||||
assertThat(metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value")).isEqualTo("direct");
|
||||
allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
|
||||
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(Arrays.asList("direct", "meta")));
|
||||
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<>(Arrays.asList("direct", "meta")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class CollectionUtilsTests {
|
||||
void isEmpty() {
|
||||
assertThat(CollectionUtils.isEmpty((Set<Object>) null)).isTrue();
|
||||
assertThat(CollectionUtils.isEmpty((Map<String, String>) null)).isTrue();
|
||||
assertThat(CollectionUtils.isEmpty(new HashMap<String, String>())).isTrue();
|
||||
assertThat(CollectionUtils.isEmpty(new HashMap<>())).isTrue();
|
||||
assertThat(CollectionUtils.isEmpty(new HashSet<>())).isTrue();
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
|
||||
@@ -77,7 +77,7 @@ class DestinationResolvingMessagingTemplateTests {
|
||||
void sendNoDestinationResolver() {
|
||||
TestDestinationResolvingMessagingTemplate template = new TestDestinationResolvingMessagingTemplate();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
template.send("myChannel", new GenericMessage<Object>("payload")));
|
||||
template.send("myChannel", new GenericMessage<>("payload")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -67,7 +67,7 @@ class MessageRequestReplyTemplateTests {
|
||||
@Test
|
||||
void sendAndReceiveMissingDestination() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
this.template.sendAndReceive(new GenericMessage<Object>("request")));
|
||||
this.template.sendAndReceive(new GenericMessage<>("request")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -103,7 +103,7 @@ class SimpAttributesContextHolderTests {
|
||||
@Test
|
||||
void setAttributesFromMessageWithMissingSessionId() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
SimpAttributesContextHolder.setAttributesFromMessage(new GenericMessage<Object>("")))
|
||||
SimpAttributesContextHolder.setAttributesFromMessage(new GenericMessage<>("")))
|
||||
.withMessageStartingWith("No session id in");
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class SimpMessagingTemplateTests {
|
||||
void convertAndSendWithCustomHeaderNonNative() {
|
||||
Map<String, Object> headers = new HashMap<>();
|
||||
headers.put("key", "value");
|
||||
headers.put(NativeMessageHeaderAccessor.NATIVE_HEADERS, new LinkedMultiValueMap<String, String>());
|
||||
headers.put(NativeMessageHeaderAccessor.NATIVE_HEADERS, new LinkedMultiValueMap<>());
|
||||
this.messagingTemplate.convertAndSend("/foo", "data", headers);
|
||||
|
||||
List<Message<byte[]>> messages = this.messageChannel.getMessages();
|
||||
|
||||
@@ -69,7 +69,7 @@ class BrokerMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
void handleMessageWhenBrokerNotRunning() {
|
||||
this.handler.handleMessage(new GenericMessage<Object>("payload"));
|
||||
this.handler.handleMessage(new GenericMessage<>("payload"));
|
||||
assertThat(this.handler.messages).isEqualTo(Collections.emptyList());
|
||||
}
|
||||
|
||||
|
||||
@@ -75,8 +75,8 @@ class HttpEntityTests {
|
||||
assertThat(new HttpEntity<>(map1).equals(new HttpEntity<>(map1))).isTrue();
|
||||
assertThat(new HttpEntity<>(map1).equals(new HttpEntity<>(map2))).isFalse();
|
||||
|
||||
assertThat(new HttpEntity<String>(null, null).equals(new HttpEntity<String>(null, null))).isTrue();
|
||||
assertThat(new HttpEntity<>("foo", null).equals(new HttpEntity<String>(null, null))).isFalse();
|
||||
assertThat(new HttpEntity<String>(null, null).equals(new HttpEntity<>(null, null))).isTrue();
|
||||
assertThat(new HttpEntity<>("foo", null).equals(new HttpEntity<>(null, null))).isFalse();
|
||||
assertThat(new HttpEntity<String>(null, null).equals(new HttpEntity<>("bar", null))).isFalse();
|
||||
|
||||
assertThat(new HttpEntity<>("foo", map1).equals(new HttpEntity<>("foo", map1))).isTrue();
|
||||
|
||||
@@ -53,7 +53,7 @@ class FormHttpMessageReaderTests extends AbstractLeakCheckingTests {
|
||||
MediaType.APPLICATION_FORM_URLENCODED)).isTrue();
|
||||
|
||||
assertThat(this.reader.canRead(
|
||||
ResolvableType.forInstance(new LinkedMultiValueMap<String, String>()),
|
||||
ResolvableType.forInstance(new LinkedMultiValueMap<>()),
|
||||
MediaType.APPLICATION_FORM_URLENCODED)).isTrue();
|
||||
|
||||
assertThat(this.reader.canRead(
|
||||
|
||||
@@ -52,7 +52,7 @@ class FormHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
|
||||
// No generic information
|
||||
assertThat(this.writer.canWrite(
|
||||
ResolvableType.forInstance(new LinkedMultiValueMap<String, String>()),
|
||||
ResolvableType.forInstance(new LinkedMultiValueMap<>()),
|
||||
MediaType.APPLICATION_FORM_URLENCODED)).isTrue();
|
||||
|
||||
assertThat(this.writer.canWrite(
|
||||
|
||||
@@ -72,7 +72,7 @@ class WebAsyncManagerTests {
|
||||
.withMessage("AsyncWebRequest must not be null");
|
||||
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> manager.startDeferredResultProcessing(new DeferredResult<String>()))
|
||||
.isThrownBy(() -> manager.startDeferredResultProcessing(new DeferredResult<>()))
|
||||
.withMessage("AsyncWebRequest must not be null");
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class ModelFactoryOrderingTests {
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
this.mavContainer.addAttribute("methods", new ArrayList<String>());
|
||||
this.mavContainer.addAttribute("methods", new ArrayList<>());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -101,7 +101,7 @@ class MethodValidationTests {
|
||||
this.request.setMethod("POST");
|
||||
this.request.setContentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
||||
this.request.addHeader("Accept", "text/plain");
|
||||
this.request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, new HashMap<String, String>(0));
|
||||
this.request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, new HashMap<>(0));
|
||||
}
|
||||
|
||||
private static RequestMappingHandlerAdapter initHandlerAdapter(Validator validator) {
|
||||
|
||||
Reference in New Issue
Block a user