DATACMNS-39 - TypeDiscoverer handles WildcardTypes now.

We now resolve the first bound from wildcard types now.
This commit is contained in:
Oliver Gierke
2011-12-02 15:34:08 +01:00
parent 6546d81b6f
commit e195abc5c9
2 changed files with 43 additions and 1 deletions

View File

@@ -157,7 +157,27 @@ public class ClassTypeInformationUnitTests {
TypeInformation<PropertyGetter> info = ClassTypeInformation.from(PropertyGetter.class);
assertThat(ClassTypeInformation.from(PropertyGetter.class), is(sameInstance(info)));
}
/**
* @see DATACMNS-39
*/
@Test
public void resolvesWildCardTypeCorrectly() {
TypeInformation<ClassWithWildCardBound> information = ClassTypeInformation.from(ClassWithWildCardBound.class);
TypeInformation<?> property = information.getProperty("wildcard");
assertThat(property.isCollectionLike(), is(true));
assertThat(property.getComponentType().getType(), is(typeCompatibleWith(String.class)));
property = information.getProperty("complexWildcard");
assertThat(property.isCollectionLike(), is(true));
TypeInformation<?> component = property.getComponentType();
assertThat(component.isCollectionLike(), is(true));
assertThat(component.getComponentType().getType(), is(typeCompatibleWith(String.class)));
}
static class StringMapContainer extends MapContainer<String> {
}
@@ -231,4 +251,9 @@ public class ClassTypeInformationUnitTests {
return _name.getBytes();
}
}
static class ClassWithWildCardBound {
List<? extends String> wildcard;
List<? extends Collection<? extends String>> complexWildcard;
}
}