DATACMNS-1198 - Added PropertyPath.getLeafType() to expose leaf-property type.

This commit is contained in:
Oliver Gierke
2017-10-19 12:25:00 +02:00
parent d2008ea3b7
commit b3e1601bc6
2 changed files with 14 additions and 0 deletions

View File

@@ -132,6 +132,15 @@ public class PropertyPath implements Streamable<PropertyPath> {
return result;
}
/**
* Returns the type of the leaf property of the current {@link PropertyPath}.
*
* @return will never be {@literal null}.
*/
public Class<?> getLeafType() {
return getLeafProperty().getType();
}
/**
* Returns the type of the property will return the plain resolved type for simple properties, the component type for
* any {@link Iterable} or the value type of a {@link java.util.Map} if the property is one.

View File

@@ -350,6 +350,11 @@ public class PropertyPathUnitTests {
assertThat(from("userName", Foo.class)).isSameAs(from("userName", Foo.class));
}
@Test // DATACMNS-1198
public void exposesLeafPropertyType() {
assertThat(from("user.name", Bar.class).getLeafType()).isEqualTo(String.class);
}
private class Foo {
String userName;