Use new Java features (switch expressions, text blocks, new JDK methods)

Closes gh-29747
This commit is contained in:
Krzysztof Krason
2022-12-28 08:59:08 +01:00
committed by Sam Brannen
parent 48abd493fe
commit afb8a0d1b1
53 changed files with 498 additions and 552 deletions

View File

@@ -378,10 +378,9 @@ public abstract class AbstractMethodMessageHandler<T>
*/
protected HandlerMethod createHandlerMethod(Object handler, Method method) {
HandlerMethod handlerMethod;
if (handler instanceof String) {
if (handler instanceof String beanName) {
ApplicationContext context = getApplicationContext();
Assert.state(context != null, "ApplicationContext is required for resolving handler bean names");
String beanName = (String) handler;
handlerMethod = new HandlerMethod(beanName, context.getAutowireCapableBeanFactory(), method);
}
else {

View File

@@ -93,10 +93,9 @@ public class GenericMessage<T> implements Message<T>, Serializable {
if (this == other) {
return true;
}
if (!(other instanceof GenericMessage)) {
if (!(other instanceof GenericMessage<?> otherMsg)) {
return false;
}
GenericMessage<?> otherMsg = (GenericMessage<?>) other;
// Using nullSafeEquals for proper array equals comparisons
return (ObjectUtils.nullSafeEquals(this.payload, otherMsg.payload) && this.headers.equals(otherMsg.headers));
}

View File

@@ -617,8 +617,7 @@ public class MessageHeaderAccessor {
* @since 4.1
*/
public static MessageHeaderAccessor getMutableAccessor(Message<?> message) {
if (message.getHeaders() instanceof MutableMessageHeaders) {
MutableMessageHeaders mutableHeaders = (MutableMessageHeaders) message.getHeaders();
if (message.getHeaders() instanceof MutableMessageHeaders mutableHeaders) {
MessageHeaderAccessor accessor = mutableHeaders.getAccessor();
return (accessor.isMutable() ? accessor : accessor.createAccessor(message));
}