twalthr commented on a change in pull request #17550:
URL: https://github.com/apache/flink/pull/17550#discussion_r735597583



##########
File path: 
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/LogicalType.java
##########
@@ -77,6 +77,33 @@ public LogicalTypeRoot getTypeRoot() {
         return typeRoot;
     }
 
+    /**
+     * Returns whether the root of the type equals to the {@code typeRoot} or 
not.
+     *
+     * @param typeRoot The root type to check against for equality
+     */
+    public boolean is(LogicalTypeRoot typeRoot) {
+        return this.typeRoot == typeRoot;
+    }
+
+    /**
+     * Returns whether the root of the type equals to at least on of the 
{@code typeRoots} or not.
+     *
+     * @param typeRoots The root types to check against for equality
+     */
+    public boolean isAnyOf(LogicalTypeRoot... typeRoots) {
+        return Arrays.stream(typeRoots).anyMatch(tr -> this.typeRoot == tr);
+    }
+
+    /**
+     * Returns whether the family type of the type equals to the {@code 
family} or not.
+     *
+     * @param family The family type to check against for equality
+     */
+    public boolean is(LogicalTypeFamily family) {

Review comment:
       The root and family names have been designed to be statically important 
concurrently. We should keep frequently used methods as short as possible since 
everyone knows what they are doing. `type.is(NUMERIC)` or 
`type.is(CHARACTER_STRING)` reads nicer than `type.isFamily(NUMERIC)`. But this 
is just my personal opinion. In `InputTypeStrategies#logical()` we also just 
treat them equal.




-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to