From dd13f013900b546ee12367e483509ada2d27d771 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 19 Aug 2022 11:15:04 +0200 Subject: [PATCH] [jOOQ/jOOQ#13894] Add SQLDialect.precedesStrictly(SQLDialect) --- jOOQ/src/main/java/org/jooq/SQLDialect.java | 40 +++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/jOOQ/src/main/java/org/jooq/SQLDialect.java b/jOOQ/src/main/java/org/jooq/SQLDialect.java index 489e84f2dc..e995ce82f9 100644 --- a/jOOQ/src/main/java/org/jooq/SQLDialect.java +++ b/jOOQ/src/main/java/org/jooq/SQLDialect.java @@ -1209,6 +1209,46 @@ public enum SQLDialect { return other.predecessors().contains(this); } + /** + * Whether this dialect strictly precedes an other dialect from the same + * family. + *

+ * This returns: + *

+ * The above also implies that: + * + *

+ * This is useful to see if some feature is supported by "at least" + * a given dialect version. Example: + * + *

+     * 
+     * // Do this block only if the chosen dialect was before PostgreSQL 9.3-
+     * if (dialect.precedesStrictly(POSTGRES_9_3)) {
+     * }
+     *
+     * // Do this block only if the chosen dialect was before PostgreSQL 9.4-
+     * else if (dialect.precedesStrictly(POSTGRES_9_4)) {
+     * }
+     *
+     * // Fall back to post-PostgreSQL 9.4+ behaviour
+     * else {
+     * }
+     * 
+     * 
+ */ + public final boolean precedesStrictly(SQLDialect other) { + return precedes(other) && this != other; + } + /** * Check whether this dialect supports another one. *