Use pattern matching variables where appropriate
This commit is contained in:
@@ -216,10 +216,9 @@ public class Chunk<W> implements Iterable<W>, Serializable {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Chunk)) {
|
||||
if (!(obj instanceof Chunk<?> other)) {
|
||||
return false;
|
||||
}
|
||||
Chunk<?> other = (Chunk<?>) obj;
|
||||
return Objects.equals(this.items, other.items) && Objects.equals(this.skips, other.skips)
|
||||
&& Objects.equals(this.errors, other.errors) && Objects.equals(this.userData, other.userData)
|
||||
&& this.end == other.end && this.busy == other.busy;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -38,6 +38,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class DefaultFieldSet implements FieldSet {
|
||||
|
||||
@@ -669,8 +670,7 @@ public class DefaultFieldSet implements FieldSet {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof DefaultFieldSet) {
|
||||
DefaultFieldSet fs = (DefaultFieldSet) object;
|
||||
if (object instanceof DefaultFieldSet fs) {
|
||||
|
||||
if (this.tokens == null) {
|
||||
return fs.tokens == null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -53,8 +53,7 @@ public class JmsItemReader<T> implements ItemReader<T>, InitializingBean {
|
||||
*/
|
||||
public void setJmsTemplate(JmsOperations jmsTemplate) {
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
if (jmsTemplate instanceof JmsTemplate) {
|
||||
JmsTemplate template = (JmsTemplate) jmsTemplate;
|
||||
if (jmsTemplate instanceof JmsTemplate template) {
|
||||
Assert.isTrue(template.getReceiveTimeout() != JmsTemplate.RECEIVE_TIMEOUT_INDEFINITE_WAIT,
|
||||
"JmsTemplate must have a receive timeout!");
|
||||
Assert.isTrue(template.getDefaultDestination() != null || template.getDefaultDestinationName() != null,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -49,8 +49,7 @@ public class JmsItemWriter<T> implements ItemWriter<T> {
|
||||
*/
|
||||
public void setJmsTemplate(JmsOperations jmsTemplate) {
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
if (jmsTemplate instanceof JmsTemplate) {
|
||||
JmsTemplate template = (JmsTemplate) jmsTemplate;
|
||||
if (jmsTemplate instanceof JmsTemplate template) {
|
||||
Assert.isTrue(template.getDefaultDestination() != null || template.getDefaultDestinationName() != null,
|
||||
"JmsTemplate must have a defaultDestination or defaultDestinationName!");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.ClassUtils;
|
||||
* in a standalone application with no threads).
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class DefaultPropertyEditorRegistrar implements PropertyEditorRegistrar {
|
||||
@@ -67,8 +68,7 @@ public class DefaultPropertyEditorRegistrar implements PropertyEditorRegistrar {
|
||||
if (key instanceof Class<?>) {
|
||||
requiredType = (Class<?>) key;
|
||||
}
|
||||
else if (key instanceof String) {
|
||||
String className = (String) key;
|
||||
else if (key instanceof String className) {
|
||||
requiredType = ClassUtils.resolveClassName(className, getClass().getClassLoader());
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -46,6 +46,7 @@ import org.springframework.util.ClassUtils;
|
||||
* then an exception is thrown.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
public class SimpleMethodInvoker implements MethodInvoker {
|
||||
@@ -133,14 +134,13 @@ public class SimpleMethodInvoker implements MethodInvoker {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof SimpleMethodInvoker)) {
|
||||
if (!(obj instanceof SimpleMethodInvoker rhs)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
SimpleMethodInvoker rhs = (SimpleMethodInvoker) obj;
|
||||
return (rhs.method.equals(this.method)) && (rhs.object.equals(this.object));
|
||||
}
|
||||
|
||||
|
||||
@@ -204,10 +204,9 @@ public class JdbcBatchItemWriterNamedParameterTests {
|
||||
|
||||
@Override
|
||||
public boolean matches(Object actual) {
|
||||
if (!(actual instanceof SqlParameterSource[])) {
|
||||
if (!(actual instanceof SqlParameterSource[] actualArray)) {
|
||||
return false;
|
||||
}
|
||||
SqlParameterSource[] actualArray = (SqlParameterSource[]) actual;
|
||||
if (expected.length != actualArray.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2012 the original author or authors.
|
||||
* Copyright 2010-2023 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.
|
||||
@@ -39,8 +39,7 @@ public class DerbyShutdownBean implements DisposableBean {
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
logger.info("Attempting Derby database shut down on: " + dataSource);
|
||||
if (!isShutdown && dataSource != null && dataSource instanceof EmbeddedDataSource) {
|
||||
EmbeddedDataSource ds = (EmbeddedDataSource) dataSource;
|
||||
if (!isShutdown && dataSource != null && dataSource instanceof EmbeddedDataSource ds) {
|
||||
try {
|
||||
ds.setShutdownDatabase("shutdown");
|
||||
ds.getConnection();
|
||||
|
||||
Reference in New Issue
Block a user