Refactor SpiExpressionRequest split parse() into property() and path() to have fast path

property() uses a fast path for the common case that the expression is a bean property path.
This will then fall back to using parse() when that isn't the case.
This commit is contained in:
Rob Bygrave
2023-03-24 19:35:11 +13:00
parent 9982fa3682
commit 9ff240dc10
29 changed files with 99 additions and 84 deletions
@@ -26,11 +26,13 @@ public class DeployPropertyParserTest extends BaseTest {
@Test
public void depth1_path() {
Assertions.assertThat(parser().property("billingAddress.city")).isEqualTo("${billingAddress}city");
Assertions.assertThat(parser().parse("billingAddress.city")).isEqualTo("${billingAddress}city");
}
@Test
public void depth2_path() {
Assertions.assertThat(parser().property("max(billingAddress.country.name)")).isEqualTo("max(${billingAddress.country}name)");
Assertions.assertThat(parser().parse("max(billingAddress.country.name)")).isEqualTo("max(${billingAddress.country}name)");
}
@@ -69,6 +71,7 @@ public class DeployPropertyParserTest extends BaseTest {
@Test
public void unknown_path() {
Assertions.assertThat(parser().property(" foo ")).isEqualTo(" foo ");
Assertions.assertThat(parser().parse(" foo ")).isEqualTo(" foo ");
}
@@ -44,8 +44,14 @@ public class TDSpiExpressionRequest implements SpiExpressionRequest {
}
@Override
public SpiExpressionRequest append(String sqlExpression) {
sql.append(sqlExpression);
public SpiExpressionRequest append(String expression) {
sql.append(expression);
return this;
}
@Override
public SpiExpressionRequest property(String expression) {
sql.append(expression);
return this;
}