Apply "instanceof pattern matching" Eclipse clean-up in spring-context-support
This has only been applied to `src/main/java`.
This commit is contained in:
parent
0eb73c130c
commit
b3473a3e81
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -59,10 +59,9 @@ class CacheResolverAdapter implements CacheResolver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) {
|
public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) {
|
||||||
if (!(context instanceof CacheInvocationContext<?>)) {
|
if (!(context instanceof CacheInvocationContext<?> cacheInvocationContext)) {
|
||||||
throw new IllegalStateException("Unexpected context " + context);
|
throw new IllegalStateException("Unexpected context " + context);
|
||||||
}
|
}
|
||||||
CacheInvocationContext<?> cacheInvocationContext = (CacheInvocationContext<?>) context;
|
|
||||||
javax.cache.Cache<Object, Object> cache = this.target.resolveCache(cacheInvocationContext);
|
javax.cache.Cache<Object, Object> cache = this.target.resolveCache(cacheInvocationContext);
|
||||||
if (cache == null) {
|
if (cache == null) {
|
||||||
throw new IllegalStateException("Could not resolve cache for " + context + " using " + this.target);
|
throw new IllegalStateException("Could not resolve cache for " + context + " using " + this.target);
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -52,10 +52,9 @@ public abstract class JCacheOperationSourcePointcut extends StaticMethodMatcherP
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof JCacheOperationSourcePointcut)) {
|
if (!(other instanceof JCacheOperationSourcePointcut otherPc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
JCacheOperationSourcePointcut otherPc = (JCacheOperationSourcePointcut) other;
|
|
||||||
return ObjectUtils.nullSafeEquals(getCacheOperationSource(), otherPc.getCacheOperationSource());
|
return ObjectUtils.nullSafeEquals(getCacheOperationSource(), otherPc.getCacheOperationSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -43,10 +43,9 @@ public class SimpleExceptionCacheResolver extends AbstractCacheResolver {
|
||||||
@Override
|
@Override
|
||||||
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
|
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
|
||||||
BasicOperation operation = context.getOperation();
|
BasicOperation operation = context.getOperation();
|
||||||
if (!(operation instanceof CacheResultOperation)) {
|
if (!(operation instanceof CacheResultOperation cacheResultOperation)) {
|
||||||
throw new IllegalStateException("Could not extract exception cache name from " + operation);
|
throw new IllegalStateException("Could not extract exception cache name from " + operation);
|
||||||
}
|
}
|
||||||
CacheResultOperation cacheResultOperation = (CacheResultOperation) operation;
|
|
||||||
String exceptionCacheName = cacheResultOperation.getExceptionCacheName();
|
String exceptionCacheName = cacheResultOperation.getExceptionCacheName();
|
||||||
if (exceptionCacheName != null) {
|
if (exceptionCacheName != null) {
|
||||||
return Collections.singleton(exceptionCacheName);
|
return Collections.singleton(exceptionCacheName);
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -226,10 +226,9 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof SimpleMailMessage)) {
|
if (!(other instanceof SimpleMailMessage otherMessage)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SimpleMailMessage otherMessage = (SimpleMailMessage) other;
|
|
||||||
return (ObjectUtils.nullSafeEquals(this.from, otherMessage.from) &&
|
return (ObjectUtils.nullSafeEquals(this.from, otherMessage.from) &&
|
||||||
ObjectUtils.nullSafeEquals(this.replyTo, otherMessage.replyTo) &&
|
ObjectUtils.nullSafeEquals(this.replyTo, otherMessage.replyTo) &&
|
||||||
ObjectUtils.nullSafeEquals(this.to, otherMessage.to) &&
|
ObjectUtils.nullSafeEquals(this.to, otherMessage.to) &&
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -30,6 +30,7 @@ import jakarta.activation.FileTypeMap;
|
||||||
import jakarta.mail.BodyPart;
|
import jakarta.mail.BodyPart;
|
||||||
import jakarta.mail.Message;
|
import jakarta.mail.Message;
|
||||||
import jakarta.mail.MessagingException;
|
import jakarta.mail.MessagingException;
|
||||||
|
import jakarta.mail.Part;
|
||||||
import jakarta.mail.internet.AddressException;
|
import jakarta.mail.internet.AddressException;
|
||||||
import jakarta.mail.internet.InternetAddress;
|
import jakarta.mail.internet.InternetAddress;
|
||||||
import jakarta.mail.internet.MimeBodyPart;
|
import jakarta.mail.internet.MimeBodyPart;
|
||||||
|
|
@ -91,6 +92,7 @@ import org.springframework.util.Assert;
|
||||||
* on the MULTIPART_MODE constants contains more detailed information.
|
* on the MULTIPART_MODE constants contains more detailed information.
|
||||||
*
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
* @author Sam Brannen
|
||||||
* @since 19.01.2004
|
* @since 19.01.2004
|
||||||
* @see #setText(String, boolean)
|
* @see #setText(String, boolean)
|
||||||
* @see #setText(String, String)
|
* @see #setText(String, String)
|
||||||
|
|
@ -427,8 +429,8 @@ public class MimeMessageHelper {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
protected String getDefaultEncoding(MimeMessage mimeMessage) {
|
protected String getDefaultEncoding(MimeMessage mimeMessage) {
|
||||||
if (mimeMessage instanceof SmartMimeMessage) {
|
if (mimeMessage instanceof SmartMimeMessage smartMimeMessage) {
|
||||||
return ((SmartMimeMessage) mimeMessage).getDefaultEncoding();
|
return smartMimeMessage.getDefaultEncoding();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -449,8 +451,8 @@ public class MimeMessageHelper {
|
||||||
* @see ConfigurableMimeFileTypeMap
|
* @see ConfigurableMimeFileTypeMap
|
||||||
*/
|
*/
|
||||||
protected FileTypeMap getDefaultFileTypeMap(MimeMessage mimeMessage) {
|
protected FileTypeMap getDefaultFileTypeMap(MimeMessage mimeMessage) {
|
||||||
if (mimeMessage instanceof SmartMimeMessage) {
|
if (mimeMessage instanceof SmartMimeMessage smartMimeMessage) {
|
||||||
FileTypeMap fileTypeMap = ((SmartMimeMessage) mimeMessage).getDefaultFileTypeMap();
|
FileTypeMap fileTypeMap = smartMimeMessage.getDefaultFileTypeMap();
|
||||||
if (fileTypeMap != null) {
|
if (fileTypeMap != null) {
|
||||||
return fileTypeMap;
|
return fileTypeMap;
|
||||||
}
|
}
|
||||||
|
|
@ -908,7 +910,7 @@ public class MimeMessageHelper {
|
||||||
Assert.notNull(contentId, "Content ID must not be null");
|
Assert.notNull(contentId, "Content ID must not be null");
|
||||||
Assert.notNull(dataSource, "DataSource must not be null");
|
Assert.notNull(dataSource, "DataSource must not be null");
|
||||||
MimeBodyPart mimeBodyPart = new MimeBodyPart();
|
MimeBodyPart mimeBodyPart = new MimeBodyPart();
|
||||||
mimeBodyPart.setDisposition(MimeBodyPart.INLINE);
|
mimeBodyPart.setDisposition(Part.INLINE);
|
||||||
mimeBodyPart.setContentID("<" + contentId + ">");
|
mimeBodyPart.setContentID("<" + contentId + ">");
|
||||||
mimeBodyPart.setDataHandler(new DataHandler(dataSource));
|
mimeBodyPart.setDataHandler(new DataHandler(dataSource));
|
||||||
getMimeMultipart().addBodyPart(mimeBodyPart);
|
getMimeMultipart().addBodyPart(mimeBodyPart);
|
||||||
|
|
@ -990,7 +992,7 @@ public class MimeMessageHelper {
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
|
|
||||||
Assert.notNull(inputStreamSource, "InputStreamSource must not be null");
|
Assert.notNull(inputStreamSource, "InputStreamSource must not be null");
|
||||||
if (inputStreamSource instanceof Resource && ((Resource) inputStreamSource).isOpen()) {
|
if (inputStreamSource instanceof Resource resource && resource.isOpen()) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Passed-in Resource contains an open stream: invalid argument. " +
|
"Passed-in Resource contains an open stream: invalid argument. " +
|
||||||
"JavaMail requires an InputStreamSource that creates a fresh stream for every call.");
|
"JavaMail requires an InputStreamSource that creates a fresh stream for every call.");
|
||||||
|
|
@ -1018,7 +1020,7 @@ public class MimeMessageHelper {
|
||||||
Assert.notNull(dataSource, "DataSource must not be null");
|
Assert.notNull(dataSource, "DataSource must not be null");
|
||||||
try {
|
try {
|
||||||
MimeBodyPart mimeBodyPart = new MimeBodyPart();
|
MimeBodyPart mimeBodyPart = new MimeBodyPart();
|
||||||
mimeBodyPart.setDisposition(MimeBodyPart.ATTACHMENT);
|
mimeBodyPart.setDisposition(Part.ATTACHMENT);
|
||||||
mimeBodyPart.setFileName(isEncodeFilenames() ?
|
mimeBodyPart.setFileName(isEncodeFilenames() ?
|
||||||
MimeUtility.encodeText(attachmentFilename) : attachmentFilename);
|
MimeUtility.encodeText(attachmentFilename) : attachmentFilename);
|
||||||
mimeBodyPart.setDataHandler(new DataHandler(dataSource));
|
mimeBodyPart.setDataHandler(new DataHandler(dataSource));
|
||||||
|
|
@ -1095,7 +1097,7 @@ public class MimeMessageHelper {
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
|
|
||||||
Assert.notNull(inputStreamSource, "InputStreamSource must not be null");
|
Assert.notNull(inputStreamSource, "InputStreamSource must not be null");
|
||||||
if (inputStreamSource instanceof Resource && ((Resource) inputStreamSource).isOpen()) {
|
if (inputStreamSource instanceof Resource resource && resource.isOpen()) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Passed-in Resource contains an open stream: invalid argument. " +
|
"Passed-in Resource contains an open stream: invalid argument. " +
|
||||||
"JavaMail requires an InputStreamSource that creates a fresh stream for every call.");
|
"JavaMail requires an InputStreamSource that creates a fresh stream for every call.");
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -99,8 +99,7 @@ public class SchedulerAccessorBean extends SchedulerAccessor implements BeanFact
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Scheduler findScheduler(String schedulerName) throws SchedulerException {
|
protected Scheduler findScheduler(String schedulerName) throws SchedulerException {
|
||||||
if (this.beanFactory instanceof ListableBeanFactory) {
|
if (this.beanFactory instanceof ListableBeanFactory lbf) {
|
||||||
ListableBeanFactory lbf = (ListableBeanFactory) this.beanFactory;
|
|
||||||
String[] beanNames = lbf.getBeanNamesForType(Scheduler.class);
|
String[] beanNames = lbf.getBeanNamesForType(Scheduler.class);
|
||||||
for (String beanName : beanNames) {
|
for (String beanName : beanNames) {
|
||||||
Scheduler schedulerBean = (Scheduler) lbf.getBean(beanName);
|
Scheduler schedulerBean = (Scheduler) lbf.getBean(beanName);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue