tkobayas commented on code in PR #7096:
URL: https://github.com/apache/incubator-kie/pull/7096#discussion_r3967322270
##########
drools-compiler/src/main/java/org/drools/compiler/rule/builder/PatternBuilder.java:
##########
@@ -1818,6 +1823,30 @@ protected ConstraintConnectiveDescr
parseExpression(final RuleBuildContext conte
return result;
}
+ static boolean containsTernaryOperator(String expr) {
+ boolean foundQuestion = false;
+ for (int i = 0; i < expr.length(); i++) {
+ char c = expr.charAt(i);
+ if (c == '"' || c == '\'') {
+ char quote = c;
+ i++;
+ while (i < expr.length()) {
+ if (expr.charAt(i) == '\\') {
+ i++;
+ } else if (expr.charAt(i) == quote) {
+ break;
+ }
+ i++;
+ }
+ } else if (!foundQuestion && c == '?' && (i + 1 >= expr.length()
|| expr.charAt(i + 1) != '.')) {
+ foundQuestion = true;
+ } else if (foundQuestion && c == ':') {
+ return true;
+ }
+ }
+ return false;
+ }
Review Comment:
We can use a parser instead, but it may be over-killing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]