Restored isTypeMatch null behavior and refined typeToMatch parameter name

Issue: SPR-12147
This commit is contained in:
Juergen Hoeller
2015-03-23 21:57:03 +01:00
parent 44e8f7b333
commit b2308926bc
8 changed files with 63 additions and 28 deletions

View File

@@ -264,7 +264,7 @@ public interface BeanFactory {
* <p>Translates aliases back to the corresponding canonical bean name.
* Will ask the parent factory if the bean cannot be found in this factory instance.
* @param name the name of the bean to query
* @param targetType the type to match against (as a {@code ResolvableType})
* @param typeToMatch the type to match against (as a {@code ResolvableType})
* @return {@code true} if the bean type matches,
* {@code false} if it doesn't match or cannot be determined yet
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
@@ -272,7 +272,7 @@ public interface BeanFactory {
* @see #getBean
* @see #getType
*/
boolean isTypeMatch(String name, ResolvableType targetType) throws NoSuchBeanDefinitionException;
boolean isTypeMatch(String name, ResolvableType typeToMatch) throws NoSuchBeanDefinitionException;
/**
* Check whether the bean with the given name matches the specified type.
@@ -281,7 +281,7 @@ public interface BeanFactory {
* <p>Translates aliases back to the corresponding canonical bean name.
* Will ask the parent factory if the bean cannot be found in this factory instance.
* @param name the name of the bean to query
* @param targetType the type to match against (as a {@code Class})
* @param typeToMatch the type to match against (as a {@code Class})
* @return {@code true} if the bean type matches,
* {@code false} if it doesn't match or cannot be determined yet
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
@@ -289,7 +289,7 @@ public interface BeanFactory {
* @see #getBean
* @see #getType
*/
boolean isTypeMatch(String name, Class<?> targetType) throws NoSuchBeanDefinitionException;
boolean isTypeMatch(String name, Class<?> typeToMatch) throws NoSuchBeanDefinitionException;
/**
* Determine the type of the bean with the given name. More specifically,

View File

@@ -560,8 +560,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
}
@Override
public boolean isTypeMatch(String name, Class<?> targetType) throws NoSuchBeanDefinitionException {
return isTypeMatch(name, ResolvableType.forClass(targetType));
public boolean isTypeMatch(String name, Class<?> typeToMatch) throws NoSuchBeanDefinitionException {
return isTypeMatch(name, ResolvableType.forClass(typeToMatch != null ? typeToMatch : Object.class));
}
@Override

View File

@@ -169,15 +169,15 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
}
@Override
public boolean isTypeMatch(String name, ResolvableType targetType) throws NoSuchBeanDefinitionException {
public boolean isTypeMatch(String name, ResolvableType typeToMatch) throws NoSuchBeanDefinitionException {
Class<?> type = getType(name);
return (targetType == null || (type != null && targetType.isAssignableFrom(type)));
return (type != null && typeToMatch.isAssignableFrom(type));
}
@Override
public boolean isTypeMatch(String name, Class<?> targetType) throws NoSuchBeanDefinitionException {
public boolean isTypeMatch(String name, Class<?> typeToMatch) throws NoSuchBeanDefinitionException {
Class<?> type = getType(name);
return (targetType == null || (type != null && targetType.isAssignableFrom(type)));
return (typeToMatch == null || (type != null && typeToMatch.isAssignableFrom(type)));
}
@Override