We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello, Is there a way to override overloads for standard library? Below is part of my code which is not getting the expected result.
@NotNull private static final Overload OVERLOAD_MATCHES = Overload.binary(Overloads.MatchesString, (lhs, rhs) -> { System.out.println("---override matches---"); String inst = (String) lhs.value(); String target = (String) rhs.value(); boolean result = target.matches(inst); return result ? BoolT.True : BoolT.False; }); @Test public void testMatchs() { boolean result1 = XrayCEL.eval("'1234'.matches(r'\\d+')"); System.out.println(result1); // output: true boolean result2 = XrayCEL.eval("r'\\d+'.matches('1234')"); System.out.println(result2); // output: false }
My override for matches is not be called, the log message are not be printed , it still used standard library's matches.
matches
string.matches(regexString)
regexString.matches(string)
The text was updated successfully, but these errors were encountered:
Nope. The r'string' syntax means raw string. CEL has no "regex type" or so.
r'string'
So both .eval()s in your example are technically StringT.matches(StringT).
.eval()
StringT.matches(StringT)
Sorry, something went wrong.
No branches or pull requests
Hello,
Is there a way to override overloads for standard library?
Below is part of my code which is not getting the expected result.
My override for
matches
is not be called, the log message are not be printed , it still used standard library'smatches
.string.matches(regexString)
regexString.matches(string)
The text was updated successfully, but these errors were encountered: