Modernize code for diamond, isEmpty & pattern matching
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2022 the original author or authors.
|
||||
* Copyright 2014-2024 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.
|
||||
@@ -31,6 +31,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
* @since 4.1
|
||||
*/
|
||||
abstract class WebSocketAdapterParsingUtils {
|
||||
@@ -48,7 +49,7 @@ abstract class WebSocketAdapterParsingUtils {
|
||||
boolean hasDefaultProtocolHandler = StringUtils.hasText(defaultProtocolHandler);
|
||||
|
||||
if (hasProtocolHandlers || hasDefaultProtocolHandler) {
|
||||
List<BeanReference> protocolHandlerList = new ManagedList<BeanReference>();
|
||||
List<BeanReference> protocolHandlerList = new ManagedList<>();
|
||||
String[] ids = StringUtils.commaDelimitedListToStringArray(protocolHandlers);
|
||||
for (String id : ids) {
|
||||
protocolHandlerList.add(new RuntimeBeanReference(id));
|
||||
@@ -64,7 +65,7 @@ abstract class WebSocketAdapterParsingUtils {
|
||||
|
||||
String messageConverters = element.getAttribute("message-converters");
|
||||
if (StringUtils.hasText(messageConverters)) {
|
||||
List<BeanReference> messageConverterList = new ManagedList<BeanReference>();
|
||||
List<BeanReference> messageConverterList = new ManagedList<>();
|
||||
String[] ids = StringUtils.commaDelimitedListToStringArray(messageConverters);
|
||||
for (String id : ids) {
|
||||
messageConverterList.add(new RuntimeBeanReference(id));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2023 the original author or authors.
|
||||
* Copyright 2014-2024 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.
|
||||
@@ -43,6 +43,7 @@ import org.springframework.web.util.pattern.PathPatternParser;
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Chris Bono
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@@ -56,8 +57,8 @@ public class WebSocketIntegrationConfigurationInitializer implements Integration
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
if (beanFactory instanceof BeanDefinitionRegistry) {
|
||||
registerEnableWebSocketIfNecessary((BeanDefinitionRegistry) beanFactory);
|
||||
if (beanFactory instanceof BeanDefinitionRegistry beanDefinitionRegistry) {
|
||||
registerEnableWebSocketIfNecessary(beanDefinitionRegistry);
|
||||
}
|
||||
else {
|
||||
LOGGER.warn("'DelegatingWebSocketConfiguration' isn't registered because 'beanFactory'" +
|
||||
|
||||
@@ -66,6 +66,7 @@ import org.springframework.web.socket.messaging.SubProtocolHandler;
|
||||
* The {@link MessageProducerSupport} for inbound WebSocket messages.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@@ -281,15 +282,15 @@ public class WebSocketInboundChannelAdapter extends MessageProducerSupport
|
||||
|
||||
@Override
|
||||
protected void doStart() {
|
||||
if (this.webSocketContainer instanceof Lifecycle) {
|
||||
((Lifecycle) this.webSocketContainer).start();
|
||||
if (this.webSocketContainer instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() {
|
||||
if (this.webSocketContainer instanceof Lifecycle) {
|
||||
((Lifecycle) this.webSocketContainer).stop();
|
||||
if (this.webSocketContainer instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user