Use pattern matching variables where appropriate
This commit is contained in:
@@ -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.
|
||||
@@ -27,6 +27,7 @@ import org.springframework.util.ClassUtils;
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@@ -122,10 +123,9 @@ public class Entity implements Serializable {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(other instanceof Entity)) {
|
||||
if (!(other instanceof Entity entity)) {
|
||||
return false;
|
||||
}
|
||||
Entity entity = (Entity) other;
|
||||
if (id == null || entity.getId() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class JobParameter<T> implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof JobParameter)) {
|
||||
if (!(obj instanceof JobParameter rhs)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,6 @@ public class JobParameter<T> implements Serializable {
|
||||
return true;
|
||||
}
|
||||
|
||||
JobParameter rhs = (JobParameter) obj;
|
||||
return type == rhs.type && value.equals(rhs.value);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -212,10 +212,9 @@ public class StepContribution implements Serializable {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof StepContribution)) {
|
||||
if (!(obj instanceof StepContribution other)) {
|
||||
return false;
|
||||
}
|
||||
StepContribution other = (StepContribution) obj;
|
||||
return toString().equals(other.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -495,10 +495,9 @@ public class StepExecution extends Entity {
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
Object jobExecutionId = getJobExecutionId();
|
||||
if (jobExecutionId == null || !(obj instanceof StepExecution) || getId() == null) {
|
||||
if (jobExecutionId == null || !(obj instanceof StepExecution other) || getId() == null) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
StepExecution other = (StepExecution) obj;
|
||||
|
||||
return stepName.equals(other.getStepName()) && (jobExecutionId.equals(other.getJobExecutionId()))
|
||||
&& getId().equals(other.getId());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2022 the original author or authors.
|
||||
* Copyright 2022-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.
|
||||
@@ -42,8 +42,7 @@ class AutomaticJobRegistrarBeanPostProcessor implements BeanFactoryPostProcessor
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof AutomaticJobRegistrar) {
|
||||
AutomaticJobRegistrar automaticJobRegistrar = (AutomaticJobRegistrar) bean;
|
||||
if (bean instanceof AutomaticJobRegistrar automaticJobRegistrar) {
|
||||
automaticJobRegistrar.setJobLoader(new DefaultJobLoader(this.beanFactory.getBean(JobRegistry.class)));
|
||||
for (ApplicationContextFactory factory : this.beanFactory.getBeansOfType(ApplicationContextFactory.class)
|
||||
.values()) {
|
||||
|
||||
@@ -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.
|
||||
@@ -42,6 +42,7 @@ import org.springframework.util.Assert;
|
||||
* {@link Job} to launch.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class JobRegistryBeanPostProcessor
|
||||
@@ -126,8 +127,7 @@ public class JobRegistryBeanPostProcessor
|
||||
*/
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof Job) {
|
||||
Job job = (Job) bean;
|
||||
if (bean instanceof Job job) {
|
||||
try {
|
||||
String groupName = this.groupName;
|
||||
if (beanFactory != null && beanFactory.containsBean(beanName)) {
|
||||
|
||||
@@ -172,9 +172,8 @@ public abstract class AbstractFlowParser extends AbstractSingleBeanDefinitionPar
|
||||
NodeList children = element.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node node = children.item(i);
|
||||
if (node instanceof Element) {
|
||||
if (node instanceof Element child) {
|
||||
String nodeName = node.getLocalName();
|
||||
Element child = (Element) node;
|
||||
switch (nodeName) {
|
||||
case STEP_ELE -> {
|
||||
stateTransitions.addAll(stepParser.parse(child, parserContext, jobFactoryRef));
|
||||
|
||||
@@ -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.
|
||||
@@ -42,6 +42,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Dave Syer
|
||||
* @author Thomas Risberg
|
||||
* @author Josh Long
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @see JobParser
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -109,8 +110,7 @@ public abstract class AbstractStepParser {
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node nd = children.item(i);
|
||||
|
||||
if (nd instanceof Element) {
|
||||
Element nestedElement = (Element) nd;
|
||||
if (nd instanceof Element nestedElement) {
|
||||
String name = nestedElement.getLocalName();
|
||||
|
||||
if (TASKLET_ELE.equals(name)) {
|
||||
|
||||
@@ -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.
|
||||
@@ -800,12 +800,10 @@ public class StepParserStepFactoryBean<I, O> implements FactoryBean<Step>, BeanN
|
||||
SkipListener<I, O> skipListener = (SkipListener<I, O>) listener;
|
||||
skipListeners.add(skipListener);
|
||||
}
|
||||
if (listener instanceof StepExecutionListener) {
|
||||
StepExecutionListener stepExecutionListener = (StepExecutionListener) listener;
|
||||
if (listener instanceof StepExecutionListener stepExecutionListener) {
|
||||
stepExecutionListeners.add(stepExecutionListener);
|
||||
}
|
||||
if (listener instanceof ChunkListener) {
|
||||
ChunkListener chunkListener = (ChunkListener) listener;
|
||||
if (listener instanceof ChunkListener chunkListener) {
|
||||
chunkListeners.add(chunkListener);
|
||||
}
|
||||
if (listener instanceof ItemReadListener) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -20,6 +20,7 @@ package org.springframework.batch.core.job.flow;
|
||||
*
|
||||
* @author Dan Garrette
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
public class FlowExecutionStatus implements Comparable<FlowExecutionStatus> {
|
||||
@@ -127,10 +128,9 @@ public class FlowExecutionStatus implements Comparable<FlowExecutionStatus> {
|
||||
if (object == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(object instanceof FlowExecutionStatus)) {
|
||||
if (!(object instanceof FlowExecutionStatus other)) {
|
||||
return false;
|
||||
}
|
||||
FlowExecutionStatus other = (FlowExecutionStatus) object;
|
||||
return name.equals(other.name);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -95,8 +95,7 @@ public class FlowJob extends AbstractJob {
|
||||
private void findSteps(Flow flow, Map<String, Step> map) {
|
||||
|
||||
for (State state : flow.getStates()) {
|
||||
if (state instanceof StepLocator) {
|
||||
StepLocator locator = (StepLocator) state;
|
||||
if (state instanceof StepLocator locator) {
|
||||
for (String name : locator.getStepNames()) {
|
||||
map.put(name, locator.getStep(name));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.batch.support.MethodInvoker;
|
||||
* which returns ExitStatus.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
* @see MethodInvoker
|
||||
*/
|
||||
@@ -86,10 +87,9 @@ public class MethodInvokerMethodInterceptor implements MethodInterceptor {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof MethodInvokerMethodInterceptor)) {
|
||||
if (!(obj instanceof MethodInvokerMethodInterceptor other)) {
|
||||
return false;
|
||||
}
|
||||
MethodInvokerMethodInterceptor other = (MethodInvokerMethodInterceptor) obj;
|
||||
return invokerMap.equals(other.invokerMap);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -34,6 +34,7 @@ import org.springframework.util.StringValueResolver;
|
||||
* ScopeSupport.
|
||||
*
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 3.0
|
||||
*/
|
||||
public abstract class BatchScopeSupport implements Scope, BeanFactoryPostProcessor, Ordered {
|
||||
@@ -194,8 +195,7 @@ public abstract class BatchScopeSupport implements Scope, BeanFactoryPostProcess
|
||||
definition = (BeanDefinition) value;
|
||||
beanName = BeanDefinitionReaderUtils.generateBeanName(definition, registry);
|
||||
}
|
||||
else if (value instanceof BeanDefinitionHolder) {
|
||||
BeanDefinitionHolder holder = (BeanDefinitionHolder) value;
|
||||
else if (value instanceof BeanDefinitionHolder holder) {
|
||||
definition = holder.getBeanDefinition();
|
||||
beanName = holder.getBeanName();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -201,13 +201,12 @@ public class JobContext extends SynchronizedAttributeAccessor {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof JobContext)) {
|
||||
if (!(other instanceof JobContext context)) {
|
||||
return false;
|
||||
}
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
JobContext context = (JobContext) other;
|
||||
if (context.jobExecution == jobExecution) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -243,13 +243,12 @@ public class StepContext extends SynchronizedAttributeAccessor {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof StepContext)) {
|
||||
if (!(other instanceof StepContext context)) {
|
||||
return false;
|
||||
}
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
StepContext context = (StepContext) other;
|
||||
if (context.stepExecution == stepExecution) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user