Skip to content

Commit 9517815

Browse files
Modernize code for diamond operator
* Use `isEmpty()` instead for length for `String` or `Collection`
1 parent 872a564 commit 9517815

28 files changed

+100
-73
lines changed

spring-amqp/src/main/java/org/springframework/amqp/core/AbstractBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
* Base class for builders supporting arguments.
2424
*
2525
* @author Gary Russell
26+
* @author Ngoc Nhan
2627
* @since 1.6
2728
*
2829
*/
@@ -36,7 +37,7 @@ public abstract class AbstractBuilder {
3637
*/
3738
protected Map<String, Object> getOrCreateArguments() {
3839
if (this.arguments == null) {
39-
this.arguments = new LinkedHashMap<String, Object>();
40+
this.arguments = new LinkedHashMap<>();
4041
}
4142
return this.arguments;
4243
}

spring-amqp/src/main/java/org/springframework/amqp/core/AbstractDeclarable.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
3434
*
3535
* @author Gary Russell
3636
* @author Christian Tzolov
37+
* @author Ngoc Nhan
3738
* @since 1.2
3839
*
3940
*/
@@ -43,7 +44,7 @@ public abstract class AbstractDeclarable implements Declarable {
4344

4445
private boolean shouldDeclare = true;
4546

46-
private Collection<Object> declaringAdmins = new ArrayList<Object>();
47+
private Collection<Object> declaringAdmins = new ArrayList<>();
4748

4849
private boolean ignoreDeclarationExceptions;
4950

@@ -63,7 +64,7 @@ public AbstractDeclarable(@Nullable Map<String, Object> arguments) {
6364
this.arguments = new HashMap<>(arguments);
6465
}
6566
else {
66-
this.arguments = new HashMap<String, Object>();
67+
this.arguments = new HashMap<>();
6768
}
6869
}
6970

@@ -102,7 +103,7 @@ public void setIgnoreDeclarationExceptions(boolean ignoreDeclarationExceptions)
102103

103104
@Override
104105
public void setAdminsThatShouldDeclare(Object... adminArgs) {
105-
Collection<Object> admins = new ArrayList<Object>();
106+
Collection<Object> admins = new ArrayList<>();
106107
if (adminArgs != null) {
107108
if (adminArgs.length > 1) {
108109
Assert.noNullElements(adminArgs, "'admins' cannot contain null elements");

spring-amqp/src/main/java/org/springframework/amqp/core/BindingBuilder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030
* @author Mark Fisher
3131
* @author Dave Syer
3232
* @author Gary Russell
33+
* @author Ngoc Nhan
3334
*/
3435
public final class BindingBuilder {
3536

@@ -50,7 +51,7 @@ public static DestinationConfigurer bind(Exchange exchange) {
5051
}
5152

5253
private static Map<String, Object> createMapForKeys(String... keys) {
53-
Map<String, Object> map = new HashMap<String, Object>();
54+
Map<String, Object> map = new HashMap<>();
5455
for (String key : keys) {
5556
map.put(key, null);
5657
}
@@ -155,7 +156,7 @@ public Binding exists() {
155156
}
156157

157158
public Binding matches(Object value) {
158-
Map<String, Object> map = new HashMap<String, Object>();
159+
Map<String, Object> map = new HashMap<>();
159160
map.put(this.key, value);
160161
return new Binding(HeadersExchangeMapConfigurer.this.destination.queue,
161162
HeadersExchangeMapConfigurer.this.destination.name,
@@ -194,7 +195,7 @@ public final class HeadersExchangeMapBindingCreator {
194195

195196
HeadersExchangeMapBindingCreator(Map<String, Object> headerMap, boolean matchAll) {
196197
Assert.notEmpty(headerMap, "header map must not be empty");
197-
this.headerMap = new HashMap<String, Object>(headerMap);
198+
this.headerMap = new HashMap<>(headerMap);
198199
this.headerMap.put("x-match", (matchAll ? "all" : "any"));
199200
}
200201

spring-amqp/src/main/java/org/springframework/amqp/support/SimpleAmqpHeaderMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
* @author Artem Bilan
5050
* @author Stephane Nicoll
5151
* @author Raylax Grey
52+
* @author Ngoc Nhan
5253
* @since 1.4
5354
*/
5455
public class SimpleAmqpHeaderMapper extends AbstractHeaderMapper<MessageProperties> implements AmqpHeaderMapper {
@@ -125,7 +126,7 @@ public void fromHeaders(MessageHeaders headers, MessageProperties amqpMessagePro
125126

126127
@Override
127128
public MessageHeaders toHeaders(MessageProperties amqpMessageProperties) {
128-
Map<String, Object> headers = new HashMap<String, Object>();
129+
Map<String, Object> headers = new HashMap<>();
129130
try {
130131
BiConsumer<String, Object> putObject = headers::put;
131132
BiConsumer<String, String> putString = headers::put;

spring-amqp/src/main/java/org/springframework/amqp/support/converter/AbstractJavaTypeMapper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@
3535
* @author Sam Nelson
3636
* @author Andreas Asplund
3737
* @author Gary Russell
38+
* @author Ngoc Nhan
3839
*/
3940
public abstract class AbstractJavaTypeMapper implements BeanClassLoaderAware {
4041

@@ -44,9 +45,9 @@ public abstract class AbstractJavaTypeMapper implements BeanClassLoaderAware {
4445

4546
public static final String DEFAULT_KEY_CLASSID_FIELD_NAME = "__KeyTypeId__";
4647

47-
private final Map<String, Class<?>> idClassMapping = new HashMap<String, Class<?>>();
48+
private final Map<String, Class<?>> idClassMapping = new HashMap<>();
4849

49-
private final Map<Class<?>, String> classIdMapping = new HashMap<Class<?>, String>();
50+
private final Map<Class<?>, String> classIdMapping = new HashMap<>();
5051

5152
private ClassLoader classLoader = ClassUtils.getDefaultClassLoader();
5253

spring-amqp/src/main/java/org/springframework/amqp/support/converter/AllowedListDeserializingMessageConverter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,12 +27,13 @@
2727
* MessageConverters that potentially use Java deserialization.
2828
*
2929
* @author Gary Russell
30+
* @author Ngoc Nhan
3031
* @since 1.5.5
3132
*
3233
*/
3334
public abstract class AllowedListDeserializingMessageConverter extends AbstractMessageConverter {
3435

35-
private final Set<String> allowedListPatterns = new LinkedHashSet<String>();
36+
private final Set<String> allowedListPatterns = new LinkedHashSet<>();
3637

3738
/**
3839
* Set simple patterns for allowable packages/classes for deserialization.

spring-amqp/src/main/java/org/springframework/amqp/support/converter/ContentTypeDelegatingMessageConverter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2019 the original author or authors.
2+
* Copyright 2015-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,11 +33,12 @@
3333
* @author Eric Rizzo
3434
* @author Gary Russell
3535
* @author Artem Bilan
36+
* @author Ngoc Nhan
3637
* @since 1.4.2
3738
*/
3839
public class ContentTypeDelegatingMessageConverter implements MessageConverter {
3940

40-
private final Map<String, MessageConverter> delegates = new HashMap<String, MessageConverter>();
41+
private final Map<String, MessageConverter> delegates = new HashMap<>();
4142

4243
private final MessageConverter defaultConverter;
4344

spring-amqp/src/main/java/org/springframework/amqp/support/converter/DefaultJackson2JavaTypeMapper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
3636
* @author Andreas Asplund
3737
* @author Artem Bilan
3838
* @author Gary Russell
39+
* @author Ngoc Nhan
3940
*/
4041
public class DefaultJackson2JavaTypeMapper extends AbstractJavaTypeMapper implements Jackson2JavaTypeMapper {
4142

@@ -45,7 +46,7 @@ public class DefaultJackson2JavaTypeMapper extends AbstractJavaTypeMapper implem
4546
"java.lang"
4647
);
4748

48-
private final Set<String> trustedPackages = new LinkedHashSet<String>(TRUSTED_PACKAGES);
49+
private final Set<String> trustedPackages = new LinkedHashSet<>(TRUSTED_PACKAGES);
4950

5051
private volatile TypePrecedence typePrecedence = TypePrecedence.INFERRED;
5152

spring-amqp/src/main/java/org/springframework/amqp/support/postprocessor/DelegatingDecompressingPostProcessor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 the original author or authors.
2+
* Copyright 2014-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,11 +30,12 @@
3030
*
3131
* @author Gary Russell
3232
* @author David Diehl
33+
* @author Ngoc Nhan
3334
* @since 1.4.2
3435
*/
3536
public class DelegatingDecompressingPostProcessor implements MessagePostProcessor, Ordered {
3637

37-
private final Map<String, MessagePostProcessor> decompressors = new HashMap<String, MessagePostProcessor>();
38+
private final Map<String, MessagePostProcessor> decompressors = new HashMap<>();
3839

3940
private int order;
4041

spring-amqp/src/main/java/org/springframework/amqp/support/postprocessor/MessagePostProcessorUtils.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,15 +29,16 @@
2929
* Utilities for message post processors.
3030
*
3131
* @author Gary Russell
32+
* @author Ngoc Nhan
3233
* @since 1.4.2
3334
*
3435
*/
3536
public final class MessagePostProcessorUtils {
3637

3738
public static Collection<MessagePostProcessor> sort(Collection<MessagePostProcessor> processors) {
38-
List<MessagePostProcessor> priorityOrdered = new ArrayList<MessagePostProcessor>();
39-
List<MessagePostProcessor> ordered = new ArrayList<MessagePostProcessor>();
40-
List<MessagePostProcessor> unOrdered = new ArrayList<MessagePostProcessor>();
39+
List<MessagePostProcessor> priorityOrdered = new ArrayList<>();
40+
List<MessagePostProcessor> ordered = new ArrayList<>();
41+
List<MessagePostProcessor> unOrdered = new ArrayList<>();
4142
for (MessagePostProcessor processor : processors) {
4243
if (processor instanceof PriorityOrdered) {
4344
priorityOrdered.add(processor);
@@ -49,7 +50,7 @@ else if (processor instanceof Ordered) {
4950
unOrdered.add(processor);
5051
}
5152
}
52-
List<MessagePostProcessor> sorted = new ArrayList<MessagePostProcessor>();
53+
List<MessagePostProcessor> sorted = new ArrayList<>();
5354
OrderComparator.sort(priorityOrdered);
5455
sorted.addAll(priorityOrdered);
5556
OrderComparator.sort(ordered);

0 commit comments

Comments
 (0)