Apply "instanceof pattern matching" Eclipse clean-up in spring-beans
This commit also applies additional clean-up tasks such as the following. - final fields - diamond operator (<>) for anonymous inner classes - Comparator.comparing This has only been applied to `src/main/java`.
This commit is contained in:
@@ -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.
|
||||
@@ -85,10 +85,9 @@ public class BeanMetadataAttribute implements BeanMetadataElement {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof BeanMetadataAttribute)) {
|
||||
if (!(other instanceof BeanMetadataAttribute otherMa)) {
|
||||
return false;
|
||||
}
|
||||
BeanMetadataAttribute otherMa = (BeanMetadataAttribute) other;
|
||||
return (this.name.equals(otherMa.name) &&
|
||||
ObjectUtils.nullSafeEquals(this.value, otherMa.value) &&
|
||||
ObjectUtils.nullSafeEquals(this.source, otherMa.source));
|
||||
|
||||
@@ -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.
|
||||
@@ -139,7 +139,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
// Sort non-void returning write methods to guard against the ill effects of
|
||||
// non-deterministic sorting of methods returned from Class#getDeclaredMethods
|
||||
// under JDK 7. See https://bugs.java.com/view_bug.do?bug_id=7023180
|
||||
matches.sort((m1, m2) -> m2.toString().compareTo(m1.toString()));
|
||||
matches.sort(Comparator.comparing(Method::toString).reversed());
|
||||
return matches;
|
||||
}
|
||||
|
||||
@@ -188,8 +188,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
for (PropertyDescriptor pd : this.propertyDescriptors) {
|
||||
final Class<?> candidateType;
|
||||
final String candidateName = pd.getName();
|
||||
if (pd instanceof IndexedPropertyDescriptor) {
|
||||
IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
|
||||
if (pd instanceof IndexedPropertyDescriptor ipd) {
|
||||
candidateType = ipd.getIndexedPropertyType();
|
||||
if (candidateName.equals(propertyName) &&
|
||||
(candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) {
|
||||
@@ -494,10 +493,9 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof IndexedPropertyDescriptor)) {
|
||||
if (!(other instanceof IndexedPropertyDescriptor otherPd)) {
|
||||
return false;
|
||||
}
|
||||
IndexedPropertyDescriptor otherPd = (IndexedPropertyDescriptor) other;
|
||||
return (ObjectUtils.nullSafeEquals(getIndexedReadMethod(), otherPd.getIndexedReadMethod()) &&
|
||||
ObjectUtils.nullSafeEquals(getIndexedWriteMethod(), otherPd.getIndexedWriteMethod()) &&
|
||||
ObjectUtils.nullSafeEquals(getIndexedPropertyType(), otherPd.getIndexedPropertyType()) &&
|
||||
|
||||
@@ -168,10 +168,9 @@ final class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof GenericTypeAwarePropertyDescriptor)) {
|
||||
if (!(other instanceof GenericTypeAwarePropertyDescriptor otherPd)) {
|
||||
return false;
|
||||
}
|
||||
GenericTypeAwarePropertyDescriptor otherPd = (GenericTypeAwarePropertyDescriptor) other;
|
||||
return (getBeanClass().equals(otherPd.getBeanClass()) && PropertyDescriptorUtils.equals(this, otherPd));
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -221,8 +221,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
|
||||
*/
|
||||
private PropertyValue mergeIfRequired(PropertyValue newPv, PropertyValue currentPv) {
|
||||
Object value = newPv.getValue();
|
||||
if (value instanceof Mergeable) {
|
||||
Mergeable mergeable = (Mergeable) value;
|
||||
if (value instanceof Mergeable mergeable) {
|
||||
if (mergeable.isMergeEnabled()) {
|
||||
Object merged = mergeable.merge(currentPv.getValue());
|
||||
return new PropertyValue(newPv.getName(), merged);
|
||||
|
||||
@@ -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.
|
||||
@@ -192,10 +192,9 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof PropertyValue)) {
|
||||
if (!(other instanceof PropertyValue otherPv)) {
|
||||
return false;
|
||||
}
|
||||
PropertyValue otherPv = (PropertyValue) other;
|
||||
return (this.name.equals(otherPv.name) &&
|
||||
ObjectUtils.nullSafeEquals(this.value, otherPv.value) &&
|
||||
ObjectUtils.nullSafeEquals(getSource(), otherPv.getSource()));
|
||||
|
||||
@@ -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.
|
||||
@@ -161,8 +161,7 @@ public abstract class BeanFactoryUtils {
|
||||
public static String[] beanNamesForTypeIncludingAncestors(ListableBeanFactory lbf, ResolvableType type) {
|
||||
Assert.notNull(lbf, "ListableBeanFactory must not be null");
|
||||
String[] result = lbf.getBeanNamesForType(type);
|
||||
if (lbf instanceof HierarchicalBeanFactory) {
|
||||
HierarchicalBeanFactory hbf = (HierarchicalBeanFactory) lbf;
|
||||
if (lbf instanceof HierarchicalBeanFactory hbf) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
String[] parentResult = beanNamesForTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
|
||||
@@ -199,8 +198,7 @@ public abstract class BeanFactoryUtils {
|
||||
|
||||
Assert.notNull(lbf, "ListableBeanFactory must not be null");
|
||||
String[] result = lbf.getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
|
||||
if (lbf instanceof HierarchicalBeanFactory) {
|
||||
HierarchicalBeanFactory hbf = (HierarchicalBeanFactory) lbf;
|
||||
if (lbf instanceof HierarchicalBeanFactory hbf) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
String[] parentResult = beanNamesForTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
|
||||
@@ -226,8 +224,7 @@ public abstract class BeanFactoryUtils {
|
||||
public static String[] beanNamesForTypeIncludingAncestors(ListableBeanFactory lbf, Class<?> type) {
|
||||
Assert.notNull(lbf, "ListableBeanFactory must not be null");
|
||||
String[] result = lbf.getBeanNamesForType(type);
|
||||
if (lbf instanceof HierarchicalBeanFactory) {
|
||||
HierarchicalBeanFactory hbf = (HierarchicalBeanFactory) lbf;
|
||||
if (lbf instanceof HierarchicalBeanFactory hbf) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
String[] parentResult = beanNamesForTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
|
||||
@@ -263,8 +260,7 @@ public abstract class BeanFactoryUtils {
|
||||
|
||||
Assert.notNull(lbf, "ListableBeanFactory must not be null");
|
||||
String[] result = lbf.getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
|
||||
if (lbf instanceof HierarchicalBeanFactory) {
|
||||
HierarchicalBeanFactory hbf = (HierarchicalBeanFactory) lbf;
|
||||
if (lbf instanceof HierarchicalBeanFactory hbf) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
String[] parentResult = beanNamesForTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
|
||||
@@ -289,8 +285,7 @@ public abstract class BeanFactoryUtils {
|
||||
|
||||
Assert.notNull(lbf, "ListableBeanFactory must not be null");
|
||||
String[] result = lbf.getBeanNamesForAnnotation(annotationType);
|
||||
if (lbf instanceof HierarchicalBeanFactory) {
|
||||
HierarchicalBeanFactory hbf = (HierarchicalBeanFactory) lbf;
|
||||
if (lbf instanceof HierarchicalBeanFactory hbf) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
String[] parentResult = beanNamesForAnnotationIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), annotationType);
|
||||
@@ -327,8 +322,7 @@ public abstract class BeanFactoryUtils {
|
||||
Assert.notNull(lbf, "ListableBeanFactory must not be null");
|
||||
Map<String, T> result = new LinkedHashMap<>(4);
|
||||
result.putAll(lbf.getBeansOfType(type));
|
||||
if (lbf instanceof HierarchicalBeanFactory) {
|
||||
HierarchicalBeanFactory hbf = (HierarchicalBeanFactory) lbf;
|
||||
if (lbf instanceof HierarchicalBeanFactory hbf) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
|
||||
@@ -376,8 +370,7 @@ public abstract class BeanFactoryUtils {
|
||||
Assert.notNull(lbf, "ListableBeanFactory must not be null");
|
||||
Map<String, T> result = new LinkedHashMap<>(4);
|
||||
result.putAll(lbf.getBeansOfType(type, includeNonSingletons, allowEagerInit));
|
||||
if (lbf instanceof HierarchicalBeanFactory) {
|
||||
HierarchicalBeanFactory hbf = (HierarchicalBeanFactory) lbf;
|
||||
if (lbf instanceof HierarchicalBeanFactory hbf) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
|
||||
|
||||
@@ -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.
|
||||
@@ -166,8 +166,7 @@ public abstract class BeanFactoryAnnotationUtils {
|
||||
if (beanFactory instanceof ConfigurableBeanFactory) {
|
||||
BeanDefinition bd = ((ConfigurableBeanFactory) beanFactory).getMergedBeanDefinition(beanName);
|
||||
// Explicit qualifier metadata on bean definition? (typically in XML definition)
|
||||
if (bd instanceof AbstractBeanDefinition) {
|
||||
AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
|
||||
if (bd instanceof AbstractBeanDefinition abd) {
|
||||
AutowireCandidateQualifier candidate = abd.getQualifier(Qualifier.class.getName());
|
||||
if (candidate != null) {
|
||||
Object value = candidate.getAttribute(AutowireCandidateQualifier.VALUE_KEY);
|
||||
|
||||
@@ -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.
|
||||
@@ -91,11 +91,10 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC
|
||||
@SuppressWarnings("unchecked")
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
if (this.customQualifierTypes != null) {
|
||||
if (!(beanFactory instanceof DefaultListableBeanFactory)) {
|
||||
if (!(beanFactory instanceof DefaultListableBeanFactory dlbf)) {
|
||||
throw new IllegalStateException(
|
||||
"CustomAutowireConfigurer needs to operate on a DefaultListableBeanFactory");
|
||||
}
|
||||
DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory) beanFactory;
|
||||
if (!(dlbf.getAutowireCandidateResolver() instanceof QualifierAnnotationAutowireCandidateResolver)) {
|
||||
dlbf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
|
||||
}
|
||||
@@ -106,8 +105,7 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC
|
||||
if (value instanceof Class) {
|
||||
customType = (Class<? extends Annotation>) value;
|
||||
}
|
||||
else if (value instanceof String) {
|
||||
String className = (String) value;
|
||||
else if (value instanceof String className) {
|
||||
customType = (Class<? extends Annotation>) ClassUtils.resolveClassName(className, this.beanClassLoader);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -394,10 +394,9 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof LifecycleElement)) {
|
||||
if (!(other instanceof LifecycleElement otherElement)) {
|
||||
return false;
|
||||
}
|
||||
LifecycleElement otherElement = (LifecycleElement) other;
|
||||
return (this.identifier.equals(otherElement.identifier));
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -304,10 +304,9 @@ public class InjectionMetadata {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof InjectedElement)) {
|
||||
if (!(other instanceof InjectedElement otherElement)) {
|
||||
return false;
|
||||
}
|
||||
InjectedElement otherElement = (InjectedElement) other;
|
||||
return this.member.equals(otherElement.member);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -168,10 +168,9 @@ public class BeanDefinitionHolder implements BeanMetadataElement {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof BeanDefinitionHolder)) {
|
||||
if (!(other instanceof BeanDefinitionHolder otherHolder)) {
|
||||
return false;
|
||||
}
|
||||
BeanDefinitionHolder otherHolder = (BeanDefinitionHolder) other;
|
||||
return this.beanDefinition.equals(otherHolder.beanDefinition) &&
|
||||
this.beanName.equals(otherHolder.beanName) &&
|
||||
ObjectUtils.nullSafeEquals(this.aliases, otherHolder.aliases);
|
||||
|
||||
@@ -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.
|
||||
@@ -178,8 +178,7 @@ public class BeanDefinitionVisitor {
|
||||
else if (value instanceof BeanDefinitionHolder) {
|
||||
visitBeanDefinition(((BeanDefinitionHolder) value).getBeanDefinition());
|
||||
}
|
||||
else if (value instanceof RuntimeBeanReference) {
|
||||
RuntimeBeanReference ref = (RuntimeBeanReference) value;
|
||||
else if (value instanceof RuntimeBeanReference ref) {
|
||||
String newBeanName = resolveStringValue(ref.getBeanName());
|
||||
if (newBeanName == null) {
|
||||
return null;
|
||||
@@ -188,8 +187,7 @@ public class BeanDefinitionVisitor {
|
||||
return new RuntimeBeanReference(newBeanName);
|
||||
}
|
||||
}
|
||||
else if (value instanceof RuntimeBeanNameReference) {
|
||||
RuntimeBeanNameReference ref = (RuntimeBeanNameReference) value;
|
||||
else if (value instanceof RuntimeBeanNameReference ref) {
|
||||
String newBeanName = resolveStringValue(ref.getBeanName());
|
||||
if (newBeanName == null) {
|
||||
return null;
|
||||
@@ -210,8 +208,7 @@ public class BeanDefinitionVisitor {
|
||||
else if (value instanceof Map) {
|
||||
visitMap((Map) value);
|
||||
}
|
||||
else if (value instanceof TypedStringValue) {
|
||||
TypedStringValue typedStringValue = (TypedStringValue) value;
|
||||
else if (value instanceof TypedStringValue typedStringValue) {
|
||||
String stringValue = typedStringValue.getValue();
|
||||
if (stringValue != null) {
|
||||
String visitedString = resolveStringValue(stringValue);
|
||||
|
||||
@@ -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.
|
||||
@@ -73,10 +73,9 @@ public class BeanExpressionContext {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof BeanExpressionContext)) {
|
||||
if (!(other instanceof BeanExpressionContext otherContext)) {
|
||||
return false;
|
||||
}
|
||||
BeanExpressionContext otherContext = (BeanExpressionContext) other;
|
||||
return (this.beanFactory == otherContext.beanFactory && this.scope == otherContext.scope);
|
||||
}
|
||||
|
||||
|
||||
@@ -392,10 +392,9 @@ public class ConstructorArgumentValues {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ConstructorArgumentValues)) {
|
||||
if (!(other instanceof ConstructorArgumentValues that)) {
|
||||
return false;
|
||||
}
|
||||
ConstructorArgumentValues that = (ConstructorArgumentValues) other;
|
||||
if (this.genericArgumentValues.size() != that.genericArgumentValues.size() ||
|
||||
this.indexedArgumentValues.size() != that.indexedArgumentValues.size()) {
|
||||
return false;
|
||||
|
||||
@@ -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.
|
||||
@@ -71,10 +71,9 @@ public class RuntimeBeanNameReference implements BeanReference {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof RuntimeBeanNameReference)) {
|
||||
if (!(other instanceof RuntimeBeanNameReference that)) {
|
||||
return false;
|
||||
}
|
||||
RuntimeBeanNameReference that = (RuntimeBeanNameReference) other;
|
||||
return this.beanName.equals(that.beanName);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -135,10 +135,9 @@ public class RuntimeBeanReference implements BeanReference {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof RuntimeBeanReference)) {
|
||||
if (!(other instanceof RuntimeBeanReference that)) {
|
||||
return false;
|
||||
}
|
||||
RuntimeBeanReference that = (RuntimeBeanReference) other;
|
||||
return (this.beanName.equals(that.beanName) && this.beanType == that.beanType &&
|
||||
this.toParent == that.toParent);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -219,10 +219,9 @@ public class TypedStringValue implements BeanMetadataElement {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof TypedStringValue)) {
|
||||
if (!(other instanceof TypedStringValue otherValue)) {
|
||||
return false;
|
||||
}
|
||||
TypedStringValue otherValue = (TypedStringValue) other;
|
||||
return (ObjectUtils.nullSafeEquals(this.value, otherValue.value) &&
|
||||
ObjectUtils.nullSafeEquals(this.targetType, otherValue.targetType));
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
Closure<Object> beans = new Closure<Object>(this) {
|
||||
Closure<Object> beans = new Closure<>(this) {
|
||||
@Override
|
||||
public Object call(Object... args) {
|
||||
invokeBeanDefiningClosure((Closure<?>) args[0]);
|
||||
|
||||
@@ -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.
|
||||
@@ -36,9 +36,9 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class BeanComponentDefinition extends BeanDefinitionHolder implements ComponentDefinition {
|
||||
|
||||
private BeanDefinition[] innerBeanDefinitions;
|
||||
private final BeanDefinition[] innerBeanDefinitions;
|
||||
|
||||
private BeanReference[] beanReferences;
|
||||
private final BeanReference[] beanReferences;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -303,9 +303,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
@Override
|
||||
public void copyConfigurationFrom(ConfigurableBeanFactory otherFactory) {
|
||||
super.copyConfigurationFrom(otherFactory);
|
||||
if (otherFactory instanceof AbstractAutowireCapableBeanFactory) {
|
||||
AbstractAutowireCapableBeanFactory otherAutowireFactory =
|
||||
(AbstractAutowireCapableBeanFactory) otherFactory;
|
||||
if (otherFactory instanceof AbstractAutowireCapableBeanFactory otherAutowireFactory) {
|
||||
this.instantiationStrategy = otherAutowireFactory.instantiationStrategy;
|
||||
this.allowCircularReferences = otherAutowireFactory.allowCircularReferences;
|
||||
this.ignoredDependencyTypes.addAll(otherAutowireFactory.ignoredDependencyTypes);
|
||||
@@ -344,8 +342,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
markBeanAsCreated(beanName);
|
||||
BeanDefinition mbd = getMergedBeanDefinition(beanName);
|
||||
RootBeanDefinition bd = null;
|
||||
if (mbd instanceof RootBeanDefinition) {
|
||||
RootBeanDefinition rbd = (RootBeanDefinition) mbd;
|
||||
if (mbd instanceof RootBeanDefinition rbd) {
|
||||
bd = (rbd.isPrototype() ? rbd : rbd.cloneBeanDefinition());
|
||||
}
|
||||
if (bd == null) {
|
||||
|
||||
@@ -236,8 +236,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
setSource(original.getSource());
|
||||
copyAttributesFrom(original);
|
||||
|
||||
if (original instanceof AbstractBeanDefinition) {
|
||||
AbstractBeanDefinition originalAbd = (AbstractBeanDefinition) original;
|
||||
if (original instanceof AbstractBeanDefinition originalAbd) {
|
||||
if (originalAbd.hasBeanClass()) {
|
||||
setBeanClass(originalAbd.getBeanClass());
|
||||
}
|
||||
@@ -313,8 +312,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
setSource(other.getSource());
|
||||
copyAttributesFrom(other);
|
||||
|
||||
if (other instanceof AbstractBeanDefinition) {
|
||||
AbstractBeanDefinition otherAbd = (AbstractBeanDefinition) other;
|
||||
if (other instanceof AbstractBeanDefinition otherAbd) {
|
||||
if (otherAbd.hasBeanClass()) {
|
||||
setBeanClass(otherAbd.getBeanClass());
|
||||
}
|
||||
@@ -1178,10 +1176,9 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof AbstractBeanDefinition)) {
|
||||
if (!(other instanceof AbstractBeanDefinition that)) {
|
||||
return false;
|
||||
}
|
||||
AbstractBeanDefinition that = (AbstractBeanDefinition) other;
|
||||
return (ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName()) &&
|
||||
ObjectUtils.nullSafeEquals(this.scope, that.scope) &&
|
||||
this.abstractFlag == that.abstractFlag &&
|
||||
|
||||
@@ -1054,8 +1054,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
setCacheBeanMetadata(otherFactory.isCacheBeanMetadata());
|
||||
setBeanExpressionResolver(otherFactory.getBeanExpressionResolver());
|
||||
setConversionService(otherFactory.getConversionService());
|
||||
if (otherFactory instanceof AbstractBeanFactory) {
|
||||
AbstractBeanFactory otherAbstractFactory = (AbstractBeanFactory) otherFactory;
|
||||
if (otherFactory instanceof AbstractBeanFactory otherAbstractFactory) {
|
||||
this.propertyEditorRegistrars.addAll(otherAbstractFactory.propertyEditorRegistrars);
|
||||
this.customEditors.putAll(otherAbstractFactory.customEditors);
|
||||
this.typeConverter = otherAbstractFactory.typeConverter;
|
||||
@@ -1512,8 +1511,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
if (tempClassLoader != null) {
|
||||
dynamicLoader = tempClassLoader;
|
||||
freshResolve = true;
|
||||
if (tempClassLoader instanceof DecoratingClassLoader) {
|
||||
DecoratingClassLoader dcl = (DecoratingClassLoader) tempClassLoader;
|
||||
if (tempClassLoader instanceof DecoratingClassLoader dcl) {
|
||||
for (Class<?> typeToMatch : typesToMatch) {
|
||||
dcl.excludeClass(typeToMatch.getName());
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -198,8 +198,7 @@ abstract class AutowireUtils {
|
||||
Type methodParameterType = methodParameterTypes[i];
|
||||
Object arg = args[i];
|
||||
if (methodParameterType.equals(genericReturnType)) {
|
||||
if (arg instanceof TypedStringValue) {
|
||||
TypedStringValue typedValue = ((TypedStringValue) arg);
|
||||
if (arg instanceof TypedStringValue typedValue) {
|
||||
if (typedValue.hasTargetType()) {
|
||||
return typedValue.getTargetType();
|
||||
}
|
||||
@@ -220,8 +219,7 @@ abstract class AutowireUtils {
|
||||
}
|
||||
return method.getReturnType();
|
||||
}
|
||||
else if (methodParameterType instanceof ParameterizedType) {
|
||||
ParameterizedType parameterizedType = (ParameterizedType) methodParameterType;
|
||||
else if (methodParameterType instanceof ParameterizedType parameterizedType) {
|
||||
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
|
||||
for (Type typeArg : actualTypeArguments) {
|
||||
if (typeArg.equals(genericReturnType)) {
|
||||
@@ -233,8 +231,7 @@ abstract class AutowireUtils {
|
||||
if (arg instanceof String) {
|
||||
className = (String) arg;
|
||||
}
|
||||
else if (arg instanceof TypedStringValue) {
|
||||
TypedStringValue typedValue = ((TypedStringValue) arg);
|
||||
else if (arg instanceof TypedStringValue typedValue) {
|
||||
String targetTypeName = typedValue.getTargetTypeName();
|
||||
if (targetTypeName == null || Class.class.getName().equals(targetTypeName)) {
|
||||
className = typedValue.getValue();
|
||||
|
||||
@@ -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.
|
||||
@@ -55,6 +55,7 @@ import org.springframework.util.StringUtils;
|
||||
* Used by {@link AbstractAutowireCapableBeanFactory}.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 1.2
|
||||
* @see AbstractAutowireCapableBeanFactory
|
||||
*/
|
||||
@@ -108,12 +109,11 @@ class BeanDefinitionValueResolver {
|
||||
public Object resolveValueIfNecessary(Object argName, @Nullable Object value) {
|
||||
// We must check each value to see whether it requires a runtime reference
|
||||
// to another bean to be resolved.
|
||||
if (value instanceof RuntimeBeanReference) {
|
||||
RuntimeBeanReference ref = (RuntimeBeanReference) value;
|
||||
if (value instanceof RuntimeBeanReference ref) {
|
||||
return resolveReference(argName, ref);
|
||||
}
|
||||
else if (value instanceof RuntimeBeanNameReference) {
|
||||
String refName = ((RuntimeBeanNameReference) value).getBeanName();
|
||||
else if (value instanceof RuntimeBeanNameReference ref) {
|
||||
String refName = ref.getBeanName();
|
||||
refName = String.valueOf(doEvaluate(refName));
|
||||
if (!this.beanFactory.containsBean(refName)) {
|
||||
throw new BeanDefinitionStoreException(
|
||||
@@ -121,22 +121,20 @@ class BeanDefinitionValueResolver {
|
||||
}
|
||||
return refName;
|
||||
}
|
||||
else if (value instanceof BeanDefinitionHolder) {
|
||||
else if (value instanceof BeanDefinitionHolder bdHolder) {
|
||||
// Resolve BeanDefinitionHolder: contains BeanDefinition with name and aliases.
|
||||
BeanDefinitionHolder bdHolder = (BeanDefinitionHolder) value;
|
||||
return resolveInnerBean(argName, bdHolder.getBeanName(), bdHolder.getBeanDefinition());
|
||||
}
|
||||
else if (value instanceof BeanDefinition) {
|
||||
else if (value instanceof BeanDefinition bd) {
|
||||
// Resolve plain BeanDefinition, without contained name: use dummy name.
|
||||
BeanDefinition bd = (BeanDefinition) value;
|
||||
String innerBeanName = "(inner bean)" + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR +
|
||||
ObjectUtils.getIdentityHexString(bd);
|
||||
return resolveInnerBean(argName, innerBeanName, bd);
|
||||
}
|
||||
else if (value instanceof DependencyDescriptor) {
|
||||
else if (value instanceof DependencyDescriptor dependencyDescriptor) {
|
||||
Set<String> autowiredBeanNames = new LinkedHashSet<>(4);
|
||||
Object result = this.beanFactory.resolveDependency(
|
||||
(DependencyDescriptor) value, this.beanName, autowiredBeanNames, this.typeConverter);
|
||||
dependencyDescriptor, this.beanName, autowiredBeanNames, this.typeConverter);
|
||||
for (String autowiredBeanName : autowiredBeanNames) {
|
||||
if (this.beanFactory.containsBean(autowiredBeanName)) {
|
||||
this.beanFactory.registerDependentBean(autowiredBeanName, this.beanName);
|
||||
@@ -144,16 +142,15 @@ class BeanDefinitionValueResolver {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else if (value instanceof ManagedArray) {
|
||||
else if (value instanceof ManagedArray managedArray) {
|
||||
// May need to resolve contained runtime references.
|
||||
ManagedArray array = (ManagedArray) value;
|
||||
Class<?> elementType = array.resolvedElementType;
|
||||
Class<?> elementType = managedArray.resolvedElementType;
|
||||
if (elementType == null) {
|
||||
String elementTypeName = array.getElementTypeName();
|
||||
String elementTypeName = managedArray.getElementTypeName();
|
||||
if (StringUtils.hasText(elementTypeName)) {
|
||||
try {
|
||||
elementType = ClassUtils.forName(elementTypeName, this.beanFactory.getBeanClassLoader());
|
||||
array.resolvedElementType = elementType;
|
||||
managedArray.resolvedElementType = elementType;
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
// Improve the message by showing the context.
|
||||
@@ -168,27 +165,27 @@ class BeanDefinitionValueResolver {
|
||||
}
|
||||
return resolveManagedArray(argName, (List<?>) value, elementType);
|
||||
}
|
||||
else if (value instanceof ManagedList) {
|
||||
else if (value instanceof ManagedList<?> managedList) {
|
||||
// May need to resolve contained runtime references.
|
||||
return resolveManagedList(argName, (List<?>) value);
|
||||
return resolveManagedList(argName, managedList);
|
||||
}
|
||||
else if (value instanceof ManagedSet) {
|
||||
else if (value instanceof ManagedSet<?> managedSet) {
|
||||
// May need to resolve contained runtime references.
|
||||
return resolveManagedSet(argName, (Set<?>) value);
|
||||
return resolveManagedSet(argName, managedSet);
|
||||
}
|
||||
else if (value instanceof ManagedMap) {
|
||||
else if (value instanceof ManagedMap<?, ?> managedMap) {
|
||||
// May need to resolve contained runtime references.
|
||||
return resolveManagedMap(argName, (Map<?, ?>) value);
|
||||
return resolveManagedMap(argName, managedMap);
|
||||
}
|
||||
else if (value instanceof ManagedProperties) {
|
||||
Properties original = (Properties) value;
|
||||
else if (value instanceof ManagedProperties original) {
|
||||
// Properties original = managedProperties;
|
||||
Properties copy = new Properties();
|
||||
original.forEach((propKey, propValue) -> {
|
||||
if (propKey instanceof TypedStringValue) {
|
||||
propKey = evaluate((TypedStringValue) propKey);
|
||||
if (propKey instanceof TypedStringValue typedStringValue) {
|
||||
propKey = evaluate(typedStringValue);
|
||||
}
|
||||
if (propValue instanceof TypedStringValue) {
|
||||
propValue = evaluate((TypedStringValue) propValue);
|
||||
if (propValue instanceof TypedStringValue typedStringValue) {
|
||||
propValue = evaluate(typedStringValue);
|
||||
}
|
||||
if (propKey == null || propValue == null) {
|
||||
throw new BeanCreationException(
|
||||
@@ -199,9 +196,8 @@ class BeanDefinitionValueResolver {
|
||||
});
|
||||
return copy;
|
||||
}
|
||||
else if (value instanceof TypedStringValue) {
|
||||
else if (value instanceof TypedStringValue typedStringValue) {
|
||||
// Convert value to target type here.
|
||||
TypedStringValue typedStringValue = (TypedStringValue) value;
|
||||
Object valueObject = evaluate(typedStringValue);
|
||||
try {
|
||||
Class<?> resolvedTargetType = resolveTargetType(typedStringValue);
|
||||
@@ -248,11 +244,10 @@ class BeanDefinitionValueResolver {
|
||||
*/
|
||||
@Nullable
|
||||
protected Object evaluate(@Nullable Object value) {
|
||||
if (value instanceof String) {
|
||||
return doEvaluate((String) value);
|
||||
if (value instanceof String str) {
|
||||
return doEvaluate(str);
|
||||
}
|
||||
else if (value instanceof String[]) {
|
||||
String[] values = (String[]) value;
|
||||
else if (value instanceof String[] values) {
|
||||
boolean actuallyResolved = false;
|
||||
Object[] resolvedValues = new Object[values.length];
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
@@ -372,10 +367,9 @@ class BeanDefinitionValueResolver {
|
||||
}
|
||||
// Actually create the inner bean instance now...
|
||||
Object innerBean = this.beanFactory.createBean(actualInnerBeanName, mbd, null);
|
||||
if (innerBean instanceof FactoryBean) {
|
||||
if (innerBean instanceof FactoryBean<?> factoryBean) {
|
||||
boolean synthetic = mbd.isSynthetic();
|
||||
innerBean = this.beanFactory.getObjectFromFactoryBean(
|
||||
(FactoryBean<?>) innerBean, actualInnerBeanName, !synthetic);
|
||||
innerBean = this.beanFactory.getObjectFromFactoryBean(factoryBean, actualInnerBeanName, !synthetic);
|
||||
}
|
||||
if (innerBean instanceof NullBean) {
|
||||
innerBean = null;
|
||||
|
||||
@@ -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.
|
||||
@@ -160,10 +160,9 @@ public class ChildBeanDefinition extends AbstractBeanDefinition {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ChildBeanDefinition)) {
|
||||
if (!(other instanceof ChildBeanDefinition that)) {
|
||||
return false;
|
||||
}
|
||||
ChildBeanDefinition that = (ChildBeanDefinition) other;
|
||||
return (ObjectUtils.nullSafeEquals(this.parentName, that.parentName) && super.equals(other));
|
||||
}
|
||||
|
||||
|
||||
@@ -310,8 +310,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
@Override
|
||||
public void copyConfigurationFrom(ConfigurableBeanFactory otherFactory) {
|
||||
super.copyConfigurationFrom(otherFactory);
|
||||
if (otherFactory instanceof DefaultListableBeanFactory) {
|
||||
DefaultListableBeanFactory otherListableFactory = (DefaultListableBeanFactory) otherFactory;
|
||||
if (otherFactory instanceof DefaultListableBeanFactory otherListableFactory) {
|
||||
this.allowBeanDefinitionOverriding = otherListableFactory.allowBeanDefinitionOverriding;
|
||||
this.allowEagerClassLoading = otherListableFactory.allowEagerClassLoading;
|
||||
this.dependencyComparator = otherListableFactory.dependencyComparator;
|
||||
@@ -389,7 +388,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
|
||||
@Override
|
||||
public <T> ObjectProvider<T> getBeanProvider(ResolvableType requiredType, boolean allowEagerInit) {
|
||||
return new BeanObjectProvider<T>() {
|
||||
return new BeanObjectProvider<>() {
|
||||
@Override
|
||||
public T getObject() throws BeansException {
|
||||
T resolved = resolveBean(requiredType, null, false);
|
||||
@@ -1248,7 +1247,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
if (bean instanceof NullBean) {
|
||||
return null;
|
||||
}
|
||||
return new NamedBeanHolder<T>(beanName, adaptBeanInstance(beanName, bean, requiredType.toClass()));
|
||||
return new NamedBeanHolder<>(beanName, adaptBeanInstance(beanName, bean, requiredType.toClass()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
@@ -88,10 +88,9 @@ public class GenericBeanDefinition extends AbstractBeanDefinition {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof GenericBeanDefinition)) {
|
||||
if (!(other instanceof GenericBeanDefinition that)) {
|
||||
return false;
|
||||
}
|
||||
GenericBeanDefinition that = (GenericBeanDefinition) other;
|
||||
return (ObjectUtils.nullSafeEquals(this.parentName, that.parentName) && super.equals(other));
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -142,8 +142,7 @@ public class GenericTypeAwareAutowireCandidateResolver extends SimpleAutowireCan
|
||||
@Nullable
|
||||
protected RootBeanDefinition getResolvedDecoratedDefinition(RootBeanDefinition rbd) {
|
||||
BeanDefinitionHolder decDef = rbd.getDecoratedDefinition();
|
||||
if (decDef != null && this.beanFactory instanceof ConfigurableListableBeanFactory) {
|
||||
ConfigurableListableBeanFactory clbf = (ConfigurableListableBeanFactory) this.beanFactory;
|
||||
if (decDef != null && this.beanFactory instanceof ConfigurableListableBeanFactory clbf) {
|
||||
if (clbf.containsBeanDefinition(decDef.getBeanName())) {
|
||||
BeanDefinition dbd = clbf.getMergedBeanDefinition(decDef.getBeanName());
|
||||
if (dbd instanceof RootBeanDefinition) {
|
||||
|
||||
@@ -102,10 +102,9 @@ public class LookupOverride extends MethodOverride {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (!(other instanceof LookupOverride) || !super.equals(other)) {
|
||||
if (!(other instanceof LookupOverride that) || !super.equals(other)) {
|
||||
return false;
|
||||
}
|
||||
LookupOverride that = (LookupOverride) other;
|
||||
return (ObjectUtils.nullSafeEquals(this.method, that.method) &&
|
||||
ObjectUtils.nullSafeEquals(this.beanName, that.beanName));
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -109,10 +109,9 @@ public abstract class MethodOverride implements BeanMetadataElement {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof MethodOverride)) {
|
||||
if (!(other instanceof MethodOverride that)) {
|
||||
return false;
|
||||
}
|
||||
MethodOverride that = (MethodOverride) other;
|
||||
return (ObjectUtils.nullSafeEquals(this.methodName, that.methodName) &&
|
||||
ObjectUtils.nullSafeEquals(this.source, that.source));
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -107,10 +107,9 @@ public class MethodOverrides {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof MethodOverrides)) {
|
||||
if (!(other instanceof MethodOverrides that)) {
|
||||
return false;
|
||||
}
|
||||
MethodOverrides that = (MethodOverrides) other;
|
||||
return this.overrides.equals(that.overrides);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -363,10 +363,9 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
|
||||
int beanCount = 0;
|
||||
|
||||
for (Object key : map.keySet()) {
|
||||
if (!(key instanceof String)) {
|
||||
if (!(key instanceof String keyString)) {
|
||||
throw new IllegalArgumentException("Illegal key [" + key + "]: only Strings allowed");
|
||||
}
|
||||
String keyString = (String) key;
|
||||
if (keyString.startsWith(prefix)) {
|
||||
// Key is of form: prefix<name>.property
|
||||
String nameAndProperty = keyString.substring(prefix.length());
|
||||
@@ -519,8 +518,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
|
||||
*/
|
||||
private Object readValue(Map.Entry<?, ?> entry) {
|
||||
Object val = entry.getValue();
|
||||
if (val instanceof String) {
|
||||
String strVal = (String) val;
|
||||
if (val instanceof String strVal) {
|
||||
// If it starts with a reference prefix...
|
||||
if (strVal.startsWith(REF_PREFIX)) {
|
||||
// Expand the reference.
|
||||
|
||||
@@ -97,10 +97,9 @@ public class ReplaceOverride extends MethodOverride {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (!(other instanceof ReplaceOverride) || !super.equals(other)) {
|
||||
if (!(other instanceof ReplaceOverride that) || !super.equals(other)) {
|
||||
return false;
|
||||
}
|
||||
ReplaceOverride that = (ReplaceOverride) other;
|
||||
return (ObjectUtils.nullSafeEquals(this.methodReplacerBeanName, that.methodReplacerBeanName) &&
|
||||
ObjectUtils.nullSafeEquals(this.typeIdentifiers, that.typeIdentifiers));
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -284,7 +284,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> ObjectProvider<T> getBeanProvider(ResolvableType requiredType, boolean allowEagerInit) {
|
||||
return new ObjectProvider<T>() {
|
||||
return new ObjectProvider<>() {
|
||||
@Override
|
||||
public T getObject() throws BeansException {
|
||||
String[] beanNames = getBeanNamesForType(requiredType);
|
||||
|
||||
@@ -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.
|
||||
@@ -1186,8 +1186,7 @@ public class BeanDefinitionParserDelegate {
|
||||
Element valueEle = null;
|
||||
for (int j = 0; j < entrySubNodes.getLength(); j++) {
|
||||
Node node = entrySubNodes.item(j);
|
||||
if (node instanceof Element) {
|
||||
Element candidateEle = (Element) node;
|
||||
if (node instanceof Element candidateEle) {
|
||||
if (nodeNameEquals(candidateEle, KEY_ELEMENT)) {
|
||||
if (keyEle != null) {
|
||||
error("<entry> element is only allowed to contain one <key> sub-element", entryEle);
|
||||
|
||||
@@ -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.
|
||||
@@ -170,8 +170,7 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
|
||||
NodeList nl = root.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
Node node = nl.item(i);
|
||||
if (node instanceof Element) {
|
||||
Element ele = (Element) node;
|
||||
if (node instanceof Element ele) {
|
||||
if (delegate.isDefaultNamespace(ele)) {
|
||||
parseDefaultElement(ele, delegate);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -78,8 +78,7 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
|
||||
|
||||
@Override
|
||||
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
|
||||
if (node instanceof Attr) {
|
||||
Attr attr = (Attr) node;
|
||||
if (node instanceof Attr attr) {
|
||||
String argName = StringUtils.trimWhitespace(parserContext.getDelegate().getLocalName(attr));
|
||||
String argValue = StringUtils.trimWhitespace(attr.getValue());
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -67,8 +67,7 @@ public class SimplePropertyNamespaceHandler implements NamespaceHandler {
|
||||
|
||||
@Override
|
||||
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
|
||||
if (node instanceof Attr) {
|
||||
Attr attr = (Attr) node;
|
||||
if (node instanceof Attr attr) {
|
||||
String propertyName = parserContext.getDelegate().getLocalName(attr);
|
||||
String propertyValue = attr.getValue();
|
||||
MutablePropertyValues pvs = definition.getBeanDefinition().getPropertyValues();
|
||||
|
||||
@@ -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,7 +128,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
|
||||
private final XmlValidationModeDetector validationModeDetector = new XmlValidationModeDetector();
|
||||
|
||||
private final ThreadLocal<Set<EncodedResource>> resourcesCurrentlyBeingLoaded =
|
||||
new NamedThreadLocal<Set<EncodedResource>>("XML bean definition resources currently being loaded"){
|
||||
new NamedThreadLocal<>("XML bean definition resources currently being loaded"){
|
||||
@Override
|
||||
protected Set<EncodedResource> initialValue() {
|
||||
return new HashSet<>(4);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -159,10 +159,9 @@ public class MutableSortDefinition implements SortDefinition, Serializable {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof SortDefinition)) {
|
||||
if (!(other instanceof SortDefinition otherSd)) {
|
||||
return false;
|
||||
}
|
||||
SortDefinition otherSd = (SortDefinition) other;
|
||||
return (getProperty().equals(otherSd.getProperty()) &&
|
||||
isAscending() == otherSd.isAscending() &&
|
||||
isIgnoreCase() == otherSd.isIgnoreCase());
|
||||
|
||||
Reference in New Issue
Block a user