isCompatibleWith now takes bean type itself into account as well

This commit is contained in:
Martin Lippert
2023-05-24 13:11:40 +02:00
parent 14d2556e71
commit c9b526f2f6
2 changed files with 2 additions and 1 deletions

View File

@@ -58,7 +58,7 @@ public class Bean {
}
public boolean isTypeCompatibleWith(String type) {
return supertypes.contains(type);
return type != null && ((this.type != null && this.type.equals(type)) || (supertypes.contains(type)));
}
@Override

View File

@@ -230,6 +230,7 @@ public class SpringMetamodelIndexerBeansTest {
assertTrue(beans[0].isTypeCompatibleWith("org.test.supertypes.Interface2OfBeanWithSupertypes"));
assertTrue(beans[0].isTypeCompatibleWith("org.test.supertypes.InterfaceOfAbstractBean"));
assertTrue(beans[0].isTypeCompatibleWith("org.test.supertypes.BaseClassOfAbstractBeanWithSupertypes"));
assertTrue(beans[0].isTypeCompatibleWith("org.test.BeanWithSupertypes"));
assertFalse(beans[0].isTypeCompatibleWith("java.lang.String"));
assertFalse(beans[0].isTypeCompatibleWith("java.util.Comparator"));