Apply "instanceof pattern matching" in spring-tx
This commit also applies additional clean-up tasks such as the following. - final fields This has only been applied to `src/main/java`.
This commit is contained in:
		
							parent
							
								
									b8fc79543d
								
							
						
					
					
						commit
						e9cf645b86
					
				| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2017 the original author or authors.
 | 
			
		||||
 * Copyright 2002-2021 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,7 +43,7 @@ import org.springframework.util.Assert;
 | 
			
		|||
public class SimpleBootstrapContext implements BootstrapContext {
 | 
			
		||||
 | 
			
		||||
	@Nullable
 | 
			
		||||
	private WorkManager workManager;
 | 
			
		||||
	private final WorkManager workManager;
 | 
			
		||||
 | 
			
		||||
	@Nullable
 | 
			
		||||
	private XATerminator xaTerminator;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2019 the original author or authors.
 | 
			
		||||
 * Copyright 2002-2021 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -194,10 +194,9 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa
 | 
			
		|||
		if (this == other) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		if (!(other instanceof AnnotationTransactionAttributeSource)) {
 | 
			
		||||
		if (!(other instanceof AnnotationTransactionAttributeSource otherTas)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		AnnotationTransactionAttributeSource otherTas = (AnnotationTransactionAttributeSource) other;
 | 
			
		||||
		return (this.annotationParsers.equals(otherTas.annotationParsers) &&
 | 
			
		||||
				this.publicMethodsOnly == otherTas.publicMethodsOnly);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2020 the original author or authors.
 | 
			
		||||
 * Copyright 2002-2021 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -128,8 +128,7 @@ public abstract class AbstractFallbackTransactionAttributeSource
 | 
			
		|||
			}
 | 
			
		||||
			else {
 | 
			
		||||
				String methodIdentification = ClassUtils.getQualifiedMethodName(method, targetClass);
 | 
			
		||||
				if (txAttr instanceof DefaultTransactionAttribute) {
 | 
			
		||||
					DefaultTransactionAttribute dta = (DefaultTransactionAttribute) txAttr;
 | 
			
		||||
				if (txAttr instanceof DefaultTransactionAttribute dta) {
 | 
			
		||||
					dta.setDescriptor(methodIdentification);
 | 
			
		||||
					dta.resolveAttributeStrings(this.embeddedValueResolver);
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2020 the original author or authors.
 | 
			
		||||
 * Copyright 2002-2021 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,8 @@ public class MatchAlwaysTransactionAttributeSource implements TransactionAttribu
 | 
			
		|||
	 * @see org.springframework.transaction.interceptor.TransactionAttributeEditor
 | 
			
		||||
	 */
 | 
			
		||||
	public void setTransactionAttribute(TransactionAttribute transactionAttribute) {
 | 
			
		||||
		if (transactionAttribute instanceof DefaultTransactionAttribute) {
 | 
			
		||||
			((DefaultTransactionAttribute) transactionAttribute).resolveAttributeStrings(null);
 | 
			
		||||
		if (transactionAttribute instanceof DefaultTransactionAttribute dta) {
 | 
			
		||||
			dta.resolveAttributeStrings(null);
 | 
			
		||||
		}
 | 
			
		||||
		this.transactionAttribute = transactionAttribute;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -68,10 +68,9 @@ public class MatchAlwaysTransactionAttributeSource implements TransactionAttribu
 | 
			
		|||
		if (this == other) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		if (!(other instanceof MatchAlwaysTransactionAttributeSource)) {
 | 
			
		||||
		if (!(other instanceof MatchAlwaysTransactionAttributeSource otherTas)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		MatchAlwaysTransactionAttributeSource otherTas = (MatchAlwaysTransactionAttributeSource) other;
 | 
			
		||||
		return ObjectUtils.nullSafeEquals(this.transactionAttribute, otherTas.transactionAttribute);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2020 the original author or authors.
 | 
			
		||||
 * Copyright 2002-2021 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -199,8 +199,8 @@ public class MethodMapTransactionAttributeSource
 | 
			
		|||
		if (logger.isDebugEnabled()) {
 | 
			
		||||
			logger.debug("Adding transactional method [" + method + "] with attribute [" + attr + "]");
 | 
			
		||||
		}
 | 
			
		||||
		if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute) {
 | 
			
		||||
			((DefaultTransactionAttribute) attr).resolveAttributeStrings(this.embeddedValueResolver);
 | 
			
		||||
		if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute dta) {
 | 
			
		||||
			dta.resolveAttributeStrings(this.embeddedValueResolver);
 | 
			
		||||
		}
 | 
			
		||||
		this.transactionAttributeMap.put(method, attr);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -242,10 +242,9 @@ public class MethodMapTransactionAttributeSource
 | 
			
		|||
		if (this == other) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		if (!(other instanceof MethodMapTransactionAttributeSource)) {
 | 
			
		||||
		if (!(other instanceof MethodMapTransactionAttributeSource otherTas)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		MethodMapTransactionAttributeSource otherTas = (MethodMapTransactionAttributeSource) other;
 | 
			
		||||
		return ObjectUtils.nullSafeEquals(this.methodMap, otherTas.methodMap);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2020 the original author or authors.
 | 
			
		||||
 * Copyright 2002-2021 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -101,8 +101,8 @@ public class NameMatchTransactionAttributeSource
 | 
			
		|||
		if (logger.isDebugEnabled()) {
 | 
			
		||||
			logger.debug("Adding transactional method [" + methodName + "] with attribute [" + attr + "]");
 | 
			
		||||
		}
 | 
			
		||||
		if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute) {
 | 
			
		||||
			((DefaultTransactionAttribute) attr).resolveAttributeStrings(this.embeddedValueResolver);
 | 
			
		||||
		if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute dta) {
 | 
			
		||||
			dta.resolveAttributeStrings(this.embeddedValueResolver);
 | 
			
		||||
		}
 | 
			
		||||
		this.nameMap.put(methodName, attr);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -115,8 +115,8 @@ public class NameMatchTransactionAttributeSource
 | 
			
		|||
	@Override
 | 
			
		||||
	public void afterPropertiesSet()  {
 | 
			
		||||
		for (TransactionAttribute attr : this.nameMap.values()) {
 | 
			
		||||
			if (attr instanceof DefaultTransactionAttribute) {
 | 
			
		||||
				((DefaultTransactionAttribute) attr).resolveAttributeStrings(this.embeddedValueResolver);
 | 
			
		||||
			if (attr instanceof DefaultTransactionAttribute dta) {
 | 
			
		||||
				dta.resolveAttributeStrings(this.embeddedValueResolver);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -167,10 +167,9 @@ public class NameMatchTransactionAttributeSource
 | 
			
		|||
		if (this == other) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		if (!(other instanceof NameMatchTransactionAttributeSource)) {
 | 
			
		||||
		if (!(other instanceof NameMatchTransactionAttributeSource otherTas)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		NameMatchTransactionAttributeSource otherTas = (NameMatchTransactionAttributeSource) other;
 | 
			
		||||
		return ObjectUtils.nullSafeEquals(this.nameMap, otherTas.nameMap);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2018 the original author or authors.
 | 
			
		||||
 * Copyright 2002-2021 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -129,10 +129,9 @@ public class RollbackRuleAttribute implements Serializable{
 | 
			
		|||
		if (this == other) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		if (!(other instanceof RollbackRuleAttribute)) {
 | 
			
		||||
		if (!(other instanceof RollbackRuleAttribute rhs)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		RollbackRuleAttribute rhs = (RollbackRuleAttribute) other;
 | 
			
		||||
		return this.exceptionName.equals(rhs.exceptionName);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2020 the original author or authors.
 | 
			
		||||
 * Copyright 2002-2021 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -52,10 +52,9 @@ abstract class TransactionAttributeSourcePointcut extends StaticMethodMatcherPoi
 | 
			
		|||
		if (this == other) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		if (!(other instanceof TransactionAttributeSourcePointcut)) {
 | 
			
		||||
		if (!(other instanceof TransactionAttributeSourcePointcut otherPc)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		TransactionAttributeSourcePointcut otherPc = (TransactionAttributeSourcePointcut) other;
 | 
			
		||||
		return ObjectUtils.nullSafeEquals(getTransactionAttributeSource(), otherPc.getTransactionAttributeSource());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue