Use new Java features (switch expressions, text blocks, new JDK methods)
Closes gh-29747
This commit is contained in:
committed by
Sam Brannen
parent
48abd493fe
commit
afb8a0d1b1
@@ -587,12 +587,11 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
|
||||
*/
|
||||
protected ObjectName registerBeanNameOrInstance(Object mapValue, String beanKey) throws MBeanExportException {
|
||||
try {
|
||||
if (mapValue instanceof String) {
|
||||
if (mapValue instanceof String beanName) {
|
||||
// Bean name pointing to a potentially lazy-init bean in the factory.
|
||||
if (this.beanFactory == null) {
|
||||
throw new MBeanExportException("Cannot resolve bean names if not running in a BeanFactory");
|
||||
}
|
||||
String beanName = (String) mapValue;
|
||||
if (isBeanDefinitionLazyInit(this.beanFactory, beanName)) {
|
||||
ObjectName objectName = registerLazyInit(beanName, beanKey);
|
||||
replaceNotificationListenerBeanNameKeysIfNecessary(beanName, objectName);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -90,8 +90,7 @@ public abstract class BshScriptUtils {
|
||||
throws EvalError {
|
||||
|
||||
Object result = evaluateBshScript(scriptSource, scriptInterfaces, classLoader);
|
||||
if (result instanceof Class) {
|
||||
Class<?> clazz = (Class<?>) result;
|
||||
if (result instanceof Class<?> clazz) {
|
||||
try {
|
||||
return ReflectionUtils.accessibleConstructor(clazz).newInstance();
|
||||
}
|
||||
|
||||
@@ -160,8 +160,7 @@ public class StandardScriptFactory implements ScriptFactory, BeanClassLoaderAwar
|
||||
}
|
||||
}
|
||||
|
||||
if (script instanceof Class) {
|
||||
Class<?> scriptClass = (Class<?>) script;
|
||||
if (script instanceof Class<?> scriptClass) {
|
||||
try {
|
||||
return ReflectionUtils.accessibleConstructor(scriptClass).newInstance();
|
||||
}
|
||||
|
||||
@@ -191,8 +191,7 @@ public class ResourceBundleThemeSource implements HierarchicalThemeSource, BeanC
|
||||
* @param theme the Theme to (re-)initialize
|
||||
*/
|
||||
protected void initParent(Theme theme) {
|
||||
if (theme.getMessageSource() instanceof HierarchicalMessageSource) {
|
||||
HierarchicalMessageSource messageSource = (HierarchicalMessageSource) theme.getMessageSource();
|
||||
if (theme.getMessageSource() instanceof HierarchicalMessageSource messageSource) {
|
||||
if (getParentThemeSource() != null && messageSource.getParentMessageSource() == null) {
|
||||
Theme parentTheme = getParentThemeSource().getTheme(theme.getName());
|
||||
if (parentTheme != null) {
|
||||
|
||||
@@ -852,8 +852,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
||||
if (pv.getValue() instanceof String) {
|
||||
empty = !StringUtils.hasText((String) pv.getValue());
|
||||
}
|
||||
else if (pv.getValue() instanceof String[]) {
|
||||
String[] values = (String[]) pv.getValue();
|
||||
else if (pv.getValue() instanceof String[] values) {
|
||||
empty = (values.length == 0 || !StringUtils.hasText(values[0]));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user