DATACMNS-1144 - @JsonPath now supports multiple path expressions.

Path expressions are now evaluated one by one with the first one actually available in the payload being used for value lookup. Also tweaked the default behavior to return null in case of an single, invalid path.
This commit is contained in:
Oliver Gierke
2017-08-24 12:56:19 +02:00
parent ce7a2e8ea5
commit d018757995
3 changed files with 56 additions and 21 deletions

View File

@@ -136,6 +136,16 @@ public class JsonProjectingMethodInterceptorFactoryUnitTests {
assertThat(customer.getNestedCities()).hasSize(2);
}
@Test // DATACMNS-1144
public void returnsNullForNonExistantValue() {
assertThat(customer.getName().getLastname()).isNull();
}
@Test // DATACMNS-1144
public void triesMultipleDeclaredPathsIfNotAvailable() {
assertThat(customer.getName().getSomeName()).isEqualTo(customer.getName().getFirstname());
}
interface Customer {
String getFirstname();
@@ -187,8 +197,13 @@ public class JsonProjectingMethodInterceptorFactoryUnitTests {
@JsonPath("$.firstname")
String getFirstname();
// Not available in the payload
@JsonPath("$.lastname")
String getLastname();
// First one not available in the payload
@JsonPath({ "$.lastname", "$.firstname" })
String getSomeName();
}
interface AnotherAddressProjection {