raminqaf commented on code in PR #28199:
URL: https://github.com/apache/flink/pull/28199#discussion_r3280431593
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/TraitCondition.java:
##########
@@ -68,4 +72,36 @@ static TraitCondition not(final TraitCondition condition) {
return new BuiltInCondition(
BuiltInCondition.Kind.NOT, List.of(condition), ctx ->
!condition.test(ctx));
}
+
+ /** True when either {@code left} or {@code right} evaluates to true. */
+ static TraitCondition or(final TraitCondition left, final TraitCondition
right) {
+ return new BuiltInCondition(
+ BuiltInCondition.Kind.OR,
+ List.of(left, right),
+ ctx -> left.test(ctx) || right.test(ctx));
+ }
+
+ /** True when the named scalar argument was provided by the caller. */
+ static TraitCondition argIsPresent(final String argName) {
+ return new BuiltInCondition(
+ BuiltInCondition.Kind.ARG_IS_PRESENT,
+ List.of(argName),
+ ctx -> ctx.hasScalarArgument(argName));
+ }
+
+ /**
+ * True when the named scalar argument is present and its value matches
{@code predicate}. False
+ * when the argument is absent, cannot be resolved as a literal of {@code
argClass},
+ * or {@code predicate} evaluates to `false`.
+ *
+ * <p>Use this for ad-hoc conditions on scalar literals. Prefer the named
factories above when
+ * one fits.
+ */
+ static <X> TraitCondition argMatches(
+ final String argName, final Class<X> argClass, final Predicate<X>
predicate) {
Review Comment:
nit: usually we use `T` for generics in Java
```suggestion
static <T> TraitCondition argMatches(
final String argName, final Class<T> argClass, final
Predicate<T> predicate) {
```
--
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]