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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -59,10 +59,9 @@ class CacheResolverAdapter implements CacheResolver {
|
|||
|
||||
@Override
|
||||
public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) {
|
||||
if (!(context instanceof CacheInvocationContext<?>)) {
|
||||
if (!(context instanceof CacheInvocationContext<?> cacheInvocationContext)) {
|
||||
throw new IllegalStateException("Unexpected context " + context);
|
||||
}
|
||||
CacheInvocationContext<?> cacheInvocationContext = (CacheInvocationContext<?>) context;
|
||||
javax.cache.Cache<Object, Object> cache = this.target.resolveCache(cacheInvocationContext);
|
||||
if (cache == null) {
|
||||
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");
|
||||
* 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) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof JCacheOperationSourcePointcut)) {
|
||||
if (!(other instanceof JCacheOperationSourcePointcut otherPc)) {
|
||||
return false;
|
||||
}
|
||||
JCacheOperationSourcePointcut otherPc = (JCacheOperationSourcePointcut) other;
|
||||
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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -43,10 +43,9 @@ public class SimpleExceptionCacheResolver extends AbstractCacheResolver {
|
|||
@Override
|
||||
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
|
||||
BasicOperation operation = context.getOperation();
|
||||
if (!(operation instanceof CacheResultOperation)) {
|
||||
if (!(operation instanceof CacheResultOperation cacheResultOperation)) {
|
||||
throw new IllegalStateException("Could not extract exception cache name from " + operation);
|
||||
}
|
||||
CacheResultOperation cacheResultOperation = (CacheResultOperation) operation;
|
||||
String exceptionCacheName = cacheResultOperation.getExceptionCacheName();
|
||||
if (exceptionCacheName != null) {
|
||||
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");
|
||||
* 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) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof SimpleMailMessage)) {
|
||||
if (!(other instanceof SimpleMailMessage otherMessage)) {
|
||||
return false;
|
||||
}
|
||||
SimpleMailMessage otherMessage = (SimpleMailMessage) other;
|
||||
return (ObjectUtils.nullSafeEquals(this.from, otherMessage.from) &&
|
||||
ObjectUtils.nullSafeEquals(this.replyTo, otherMessage.replyTo) &&
|
||||
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");
|
||||
* 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.Message;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.Part;
|
||||
import jakarta.mail.internet.AddressException;
|
||||
import jakarta.mail.internet.InternetAddress;
|
||||
import jakarta.mail.internet.MimeBodyPart;
|
||||
|
@ -91,6 +92,7 @@ import org.springframework.util.Assert;
|
|||
* on the MULTIPART_MODE constants contains more detailed information.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 19.01.2004
|
||||
* @see #setText(String, boolean)
|
||||
* @see #setText(String, String)
|
||||
|
@ -427,8 +429,8 @@ public class MimeMessageHelper {
|
|||
*/
|
||||
@Nullable
|
||||
protected String getDefaultEncoding(MimeMessage mimeMessage) {
|
||||
if (mimeMessage instanceof SmartMimeMessage) {
|
||||
return ((SmartMimeMessage) mimeMessage).getDefaultEncoding();
|
||||
if (mimeMessage instanceof SmartMimeMessage smartMimeMessage) {
|
||||
return smartMimeMessage.getDefaultEncoding();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -449,8 +451,8 @@ public class MimeMessageHelper {
|
|||
* @see ConfigurableMimeFileTypeMap
|
||||
*/
|
||||
protected FileTypeMap getDefaultFileTypeMap(MimeMessage mimeMessage) {
|
||||
if (mimeMessage instanceof SmartMimeMessage) {
|
||||
FileTypeMap fileTypeMap = ((SmartMimeMessage) mimeMessage).getDefaultFileTypeMap();
|
||||
if (mimeMessage instanceof SmartMimeMessage smartMimeMessage) {
|
||||
FileTypeMap fileTypeMap = smartMimeMessage.getDefaultFileTypeMap();
|
||||
if (fileTypeMap != null) {
|
||||
return fileTypeMap;
|
||||
}
|
||||
|
@ -908,7 +910,7 @@ public class MimeMessageHelper {
|
|||
Assert.notNull(contentId, "Content ID must not be null");
|
||||
Assert.notNull(dataSource, "DataSource must not be null");
|
||||
MimeBodyPart mimeBodyPart = new MimeBodyPart();
|
||||
mimeBodyPart.setDisposition(MimeBodyPart.INLINE);
|
||||
mimeBodyPart.setDisposition(Part.INLINE);
|
||||
mimeBodyPart.setContentID("<" + contentId + ">");
|
||||
mimeBodyPart.setDataHandler(new DataHandler(dataSource));
|
||||
getMimeMultipart().addBodyPart(mimeBodyPart);
|
||||
|
@ -990,7 +992,7 @@ public class MimeMessageHelper {
|
|||
throws MessagingException {
|
||||
|
||||
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(
|
||||
"Passed-in Resource contains an open stream: invalid argument. " +
|
||||
"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");
|
||||
try {
|
||||
MimeBodyPart mimeBodyPart = new MimeBodyPart();
|
||||
mimeBodyPart.setDisposition(MimeBodyPart.ATTACHMENT);
|
||||
mimeBodyPart.setDisposition(Part.ATTACHMENT);
|
||||
mimeBodyPart.setFileName(isEncodeFilenames() ?
|
||||
MimeUtility.encodeText(attachmentFilename) : attachmentFilename);
|
||||
mimeBodyPart.setDataHandler(new DataHandler(dataSource));
|
||||
|
@ -1095,7 +1097,7 @@ public class MimeMessageHelper {
|
|||
throws MessagingException {
|
||||
|
||||
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(
|
||||
"Passed-in Resource contains an open stream: invalid argument. " +
|
||||
"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");
|
||||
* 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 {
|
||||
if (this.beanFactory instanceof ListableBeanFactory) {
|
||||
ListableBeanFactory lbf = (ListableBeanFactory) this.beanFactory;
|
||||
if (this.beanFactory instanceof ListableBeanFactory lbf) {
|
||||
String[] beanNames = lbf.getBeanNamesForType(Scheduler.class);
|
||||
for (String beanName : beanNames) {
|
||||
Scheduler schedulerBean = (Scheduler) lbf.getBean(beanName);
|
||||
|
|
Loading…
Reference in New Issue