Use the diamond syntax

Closes gh-1450
This commit is contained in:
diguage 2017-06-05 19:20:22 +08:00 committed by Stephane Nicoll
parent ca1e682dc4
commit c1d44d9a34
16 changed files with 23 additions and 24 deletions

View File

@ -37,8 +37,7 @@ import org.springframework.lang.Nullable;
*/
public class MethodOverrides {
private final Set<MethodOverride> overrides =
Collections.synchronizedSet(new LinkedHashSet<MethodOverride>(0));
private final Set<MethodOverride> overrides = Collections.synchronizedSet(new LinkedHashSet<>(0));
private volatile boolean modified = false;

View File

@ -33,7 +33,7 @@ import javax.lang.model.element.TypeElement;
*/
class MetadataCollector {
private final List<ItemMetadata> metadataItems = new ArrayList<ItemMetadata>();
private final List<ItemMetadata> metadataItems = new ArrayList<>();
private final ProcessingEnvironment processingEnvironment;
@ -41,7 +41,7 @@ class MetadataCollector {
private final TypeHelper typeHelper;
private final Set<String> processedSourceTypes = new HashSet<String>();
private final Set<String> processedSourceTypes = new HashSet<>();
/**

View File

@ -362,7 +362,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
}
Collections.sort(this.members, Collections.reverseOrder());
CountDownLatch latch = new CountDownLatch(this.smartMemberCount);
Set<String> countDownBeanNames = Collections.synchronizedSet(new LinkedHashSet<String>());
Set<String> countDownBeanNames = Collections.synchronizedSet(new LinkedHashSet<>());
for (LifecycleGroupMember member : this.members) {
if (this.lifecycleBeans.containsKey(member.name)) {
doStop(this.lifecycleBeans, member.name, latch, countDownBeanNames);

View File

@ -87,7 +87,7 @@ public class RowMapperResultSetExtractor<T> implements ResultSetExtractor<List<T
@Override
public List<T> extractData(ResultSet rs) throws SQLException {
List<T> results = (this.rowsExpected > 0 ? new ArrayList<>(this.rowsExpected) : new ArrayList<T>());
List<T> results = (this.rowsExpected > 0 ? new ArrayList<>(this.rowsExpected) : new ArrayList<>());
int rowNum = 0;
while (rs.next()) {
results.add(this.rowMapper.mapRow(rs, rowNum++));

View File

@ -424,7 +424,7 @@ public abstract class AbstractMethodMessageHandler<T>
}
protected void handleMessageInternal(Message<?> message, String lookupDestination) {
List<Match> matches = new ArrayList<Match>();
List<Match> matches = new ArrayList<>();
List<T> mappingsByUrl = this.destinationLookup.get(lookupDestination);
if (mappingsByUrl != null) {

View File

@ -51,7 +51,7 @@ public class BufferingStompDecoder {
private final int bufferSizeLimit;
private final Queue<ByteBuffer> chunks = new LinkedBlockingQueue<ByteBuffer>();
private final Queue<ByteBuffer> chunks = new LinkedBlockingQueue<>();
private volatile Integer expectedContentLength;
@ -107,7 +107,7 @@ public class BufferingStompDecoder {
}
ByteBuffer bufferToDecode = assembleChunksAndReset();
MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>();
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
List<Message<byte[]>> messages = this.stompDecoder.decode(bufferToDecode, headers);
if (bufferToDecode.hasRemaining()) {

View File

@ -53,7 +53,7 @@ public class MessageReceivingTemplateTests {
@Test
public void receive() {
Message<?> expected = new GenericMessage<Object>("payload");
Message<?> expected = new GenericMessage<>("payload");
this.template.setDefaultDestination("home");
this.template.setReceiveMessage(expected);
Message<?> actual = this.template.receive();
@ -69,7 +69,7 @@ public class MessageReceivingTemplateTests {
@Test
public void receiveFromDestination() {
Message<?> expected = new GenericMessage<Object>("payload");
Message<?> expected = new GenericMessage<>("payload");
this.template.setReceiveMessage(expected);
Message<?> actual = this.template.receive("somewhere");
@ -79,7 +79,7 @@ public class MessageReceivingTemplateTests {
@Test
public void receiveAndConvert() {
Message<?> expected = new GenericMessage<Object>("payload");
Message<?> expected = new GenericMessage<>("payload");
this.template.setDefaultDestination("home");
this.template.setReceiveMessage(expected);
String payload = this.template.receiveAndConvert(String.class);
@ -90,7 +90,7 @@ public class MessageReceivingTemplateTests {
@Test
public void receiveAndConvertFromDestination() {
Message<?> expected = new GenericMessage<Object>("payload");
Message<?> expected = new GenericMessage<>("payload");
this.template.setReceiveMessage(expected);
String payload = this.template.receiveAndConvert("somewhere", String.class);
@ -100,7 +100,7 @@ public class MessageReceivingTemplateTests {
@Test
public void receiveAndConvertFailed() {
Message<?> expected = new GenericMessage<Object>("not a number test");
Message<?> expected = new GenericMessage<>("not a number test");
this.template.setReceiveMessage(expected);
this.template.setMessageConverter(new GenericMessageConverter());
@ -111,7 +111,7 @@ public class MessageReceivingTemplateTests {
@Test
public void receiveAndConvertNoConverter() {
Message<?> expected = new GenericMessage<Object>("payload");
Message<?> expected = new GenericMessage<>("payload");
this.template.setDefaultDestination("home");
this.template.setReceiveMessage(expected);
this.template.setMessageConverter(new GenericMessageConverter());

View File

@ -288,7 +288,7 @@ public class MockHttpServletRequestBuilder
*/
public MockHttpServletRequestBuilder accept(String... mediaTypes) {
Assert.notEmpty(mediaTypes, "'mediaTypes' must not be empty");
List<MediaType> result = new ArrayList<MediaType>(mediaTypes.length);
List<MediaType> result = new ArrayList<>(mediaTypes.length);
for (String mediaType : mediaTypes) {
result.add(MediaType.parseMediaType(mediaType));
}

View File

@ -45,7 +45,7 @@ public class CompositeFilter implements Filter {
public void setFilters(List<? extends Filter> filters) {
this.filters = new ArrayList<Filter>(filters);
this.filters = new ArrayList<>(filters);
}

View File

@ -52,7 +52,7 @@ class DefaultRenderingResponseBuilder implements RenderingResponse.Builder {
private final HttpHeaders headers = new HttpHeaders();
private final Map<String, Object> model = new LinkedHashMap<String, Object>();
private final Map<String, Object> model = new LinkedHashMap<>();
public DefaultRenderingResponseBuilder(String name) {

View File

@ -61,7 +61,7 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
private static Collection<HeaderExpression> parseExpressions(String... headers) {
Set<HeaderExpression> expressions = new LinkedHashSet<HeaderExpression>();
Set<HeaderExpression> expressions = new LinkedHashSet<>();
if (headers != null) {
for (String header : headers) {
HeaderExpression expr = new HeaderExpression(header);

View File

@ -301,7 +301,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
protected HandlerMethod lookupHandlerMethod(String lookupPath, ServerWebExchange exchange)
throws Exception {
List<Match> matches = new ArrayList<Match>();
List<Match> matches = new ArrayList<>();
List<T> directPathMatches = this.mappingRegistry.getMappingsByUrl(lookupPath);
if (directPathMatches != null) {
addMatchingMappings(directPathMatches, matches, exchange);

View File

@ -36,7 +36,7 @@ import org.springframework.web.servlet.HandlerExceptionResolver;
*/
class WebMvcConfigurerComposite implements WebMvcConfigurer {
private final List<WebMvcConfigurer> delegates = new ArrayList<WebMvcConfigurer>();
private final List<WebMvcConfigurer> delegates = new ArrayList<>();
public void addWebMvcConfigurers(List<WebMvcConfigurer> configurers) {

View File

@ -340,7 +340,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
*/
@Nullable
protected HandlerMethod lookupHandlerMethod(String lookupPath, HttpServletRequest request) throws Exception {
List<Match> matches = new ArrayList<Match>();
List<Match> matches = new ArrayList<>();
List<T> directPathMatches = this.mappingRegistry.getMappingsByUrl(lookupPath);
if (directPathMatches != null) {
addMatchingMappings(directPathMatches, matches, request);

View File

@ -139,7 +139,7 @@ public class WebSocketExtension {
public static List<WebSocketExtension> parseExtensions(String extensions) {
if (StringUtils.hasText(extensions)) {
String[] tokens = StringUtils.tokenizeToStringArray(extensions, ",");
List<WebSocketExtension> result = new ArrayList<WebSocketExtension>(tokens.length);
List<WebSocketExtension> result = new ArrayList<>(tokens.length);
for (String token : tokens) {
result.add(parseExtension(token));
}

View File

@ -102,7 +102,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
private MessageHeaderInitializer headerInitializer;
private final Map<String, Principal> stompAuthentications = new ConcurrentHashMap<String, Principal>();
private final Map<String, Principal> stompAuthentications = new ConcurrentHashMap<>();
private Boolean immutableMessageInterceptorPresent;