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: + *
false if this dialect is the same as the other
+ * dialecttrue if this dialect precedes the other dialect via any
+ * number of calls to {@link #predecessor()}false if the two dialects do not belong to the same
+ * family+ * 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.
*