Skip to content

First version of expression evaluation#9756

Merged
nielsm5 merged 23 commits intomasterfrom
feature/9065_ExpressionLanguageForPropertyEvaluation
Oct 16, 2025
Merged

First version of expression evaluation#9756
nielsm5 merged 23 commits intomasterfrom
feature/9065_ExpressionLanguageForPropertyEvaluation

Conversation

@tnleeuw
Copy link
Contributor

@tnleeuw tnleeuw commented Oct 9, 2025

Closes #9065

@tnleeuw tnleeuw requested a review from nielsm5 October 9, 2025 09:28
@tnleeuw tnleeuw self-assigned this Oct 9, 2025
test.expr1 = ${= ${test.vmin} * factor }

# Embedded expression should be used to reference properties that do contain dots
test.expr2 = ${= ${test.vmin} * ${test.v3} }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Het zijn nu alleen rekenvoorbeelden. Ik ben ook wel een beetje zoekende naar string concatenatie en iets met booleans. Dit moet gebruikt kunnen worden voor #8872

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Die rekenvoorbeelden waren makkelijk... Ik voeg wat meer tests toe met voorbeelden van string checks en concatenatie.

@tnleeuw tnleeuw force-pushed the feature/9065_ExpressionLanguageForPropertyEvaluation branch from 7f124c1 to 4c55e78 Compare October 13, 2025 07:53
@tnleeuw tnleeuw marked this pull request as ready for review October 14, 2025 11:49
@tnleeuw tnleeuw requested a review from a team as a code owner October 14, 2025 11:49
@tnleeuw tnleeuw requested review from evandongen and nielsm5 October 14, 2025 11:49
@tnleeuw tnleeuw force-pushed the feature/9065_ExpressionLanguageForPropertyEvaluation branch from ee7c6f5 to ab8b019 Compare October 14, 2025 16:19
Copy link
Contributor

@evandongen evandongen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ziet er goed uit, paar vragen en 1 suggestie.

@@ -50,11 +62,12 @@ private StringResolver() {

/**
* Do variable substitution on a string to resolve ${x2} to the value of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toen ik dit begon te lezen dacht ik echt dat dit 'keer twee' betekende. Na wat verder lezen wordt het duidelijk dat het 'letter x twee' betekent (-:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Veel copy-paste hier en veel bestaande doc aangepast. Maar misschien niet helemaal correct en misschien niet helemaal duidelijk.
Bedankt, ik ga er nog een beetje aan sleutelen!

int stopPos = startPos - delimStop.length();
int numEmbeddedStart = 0;
int numEmbeddedStop = 0;
startPos += delimStart.length();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done outside the loop, otherwise the start-position from which opening braces are counted shifts every iteration and we do not properly find the last closing brace!
This was an existing problem that caused some mysterious errors in property resolution occassionally even before adding the new evaluation engine.

map.put("key", "value");

// Act
Optional<String> value = embeddedScriptEvaluation.resolve("=key.toUpperCase()", map, null, null, StringResolver.DELIM_START, StringResolver.DELIM_STOP, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deze is leuk, kan je ook =${instance.name}.toUpperCase() doen? en wat gebeurd er als hij niet bestaat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je moet doen ${=instance.name.toLowerCase(), de string-referentie niet evalueren binnen de expressie want dan wordt de string als identifier gezien ipv string!

Maar ja in principe is het mogelijk om instance.name.lc nu direct in de properties-file te definieren ipv in code. En als instance.name niet is gezet, dan is het resultaat een lege string.
Er is nu ook een test voor toegevoegd.

# Embedded expression should be used to reference properties that do contain dots
test.expr2 = ${= ${test.vmin} * ${test.v3} }

str.c1 = We
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Framework

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nu beter zo, hoop ik

test.expr2 = ${= ${test.vmin} * ${test.v3} }

str.c1 = We
str.c2 = Are
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nu beter zo, hoop ik

@tnleeuw tnleeuw requested a review from nielsm5 October 15, 2025 14:53
</dependency>
<dependency>
<groupId>org.frankframework</groupId>
<artifactId>script-property-substitution</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

property-expression-evaluator

@sonarqubecloud
Copy link

@nielsm5 nielsm5 merged commit a1a8636 into master Oct 16, 2025
33 checks passed
@nielsm5 nielsm5 deleted the feature/9065_ExpressionLanguageForPropertyEvaluation branch October 16, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement an Expression Language for properties

3 participants