From 33dc2389217bc92c2429536c5e6b9bfdd8e772e9 Mon Sep 17 00:00:00 2001 From: lukaseder Date: Mon, 4 Jul 2016 18:07:02 +0200 Subject: [PATCH] [#5312] Add SQLDataType.VARCHAR(length) and other methods for convenience --- .../main/java/org/jooq/impl/SQLDataType.java | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/jOOQ/src/main/java/org/jooq/impl/SQLDataType.java b/jOOQ/src/main/java/org/jooq/impl/SQLDataType.java index bfb6a51aa9..b346ee4292 100644 --- a/jOOQ/src/main/java/org/jooq/impl/SQLDataType.java +++ b/jOOQ/src/main/java/org/jooq/impl/SQLDataType.java @@ -108,41 +108,97 @@ public final class SQLDataType { */ public static final DataType VARCHAR = new DefaultDataType(null, String.class, "varchar"); + /** + * The {@link Types#VARCHAR} type. + */ + public static final DataType VARCHAR(int length) { + return VARCHAR.length(length); + } + /** * The {@link Types#CHAR} type. */ public static final DataType CHAR = new DefaultDataType(null, String.class, "char"); + /** + * The {@link Types#CHAR} type. + */ + public static final DataType CHAR(int length) { + return CHAR.length(length); + } + /** * The {@link Types#LONGVARCHAR} type. */ public static final DataType LONGVARCHAR = new DefaultDataType(null, String.class, "longvarchar"); + /** + * The {@link Types#LONGVARCHAR} type. + */ + public static final DataType LONGVARCHAR(int length) { + return LONGVARCHAR.length(length); + } + /** * The {@link Types#CLOB} type. */ public static final DataType CLOB = new DefaultDataType(null, String.class, "clob"); + /** + * The {@link Types#CLOB} type. + */ + public static final DataType CLOB(int length) { + return CLOB.length(length); + } + /** * The {@link Types#NVARCHAR} type. */ public static final DataType NVARCHAR = new DefaultDataType(null, String.class, "nvarchar"); + /** + * The {@link Types#NVARCHAR} type. + */ + public static final DataType NVARCHAR(int length) { + return NVARCHAR.length(length); + } + /** * The {@link Types#NCHAR} type. */ public static final DataType NCHAR = new DefaultDataType(null, String.class, "nchar"); + /** + * The {@link Types#NCHAR} type. + */ + public static final DataType NCHAR(int length) { + return NCHAR.length(length); + } + /** * The {@link Types#LONGNVARCHAR} type. */ public static final DataType LONGNVARCHAR = new DefaultDataType(null, String.class, "longnvarchar"); + /** + * The {@link Types#LONGNVARCHAR} type. + */ + public static final DataType LONGNVARCHAR(int length) { + return LONGNVARCHAR.length(length); + } + /** * The {@link Types#NCLOB} type. */ public static final DataType NCLOB = new DefaultDataType(null, String.class, "nclob"); + /** + * The {@link Types#NCLOB} type. + */ + public static final DataType NCLOB(int length) { + return NCLOB.length(length); + } + // ------------------------------------------------------------------------- // Boolean types // ------------------------------------------------------------------------- @@ -238,11 +294,39 @@ public final class SQLDataType { */ public static final DataType NUMERIC = new DefaultDataType(null, BigDecimal.class, "numeric"); + /** + * The {@link Types#NUMERIC} type. + */ + public static final DataType NUMERIC(int precision) { + return NUMERIC.precision(precision); + } + + /** + * The {@link Types#NUMERIC} type. + */ + public static final DataType NUMERIC(int precision, int scale) { + return NUMERIC.precision(precision, scale); + } + /** * The {@link Types#DECIMAL} type. */ public static final DataType DECIMAL = new DefaultDataType(null, BigDecimal.class, "decimal"); + /** + * The {@link Types#DECIMAL} type. + */ + public static final DataType DECIMAL(int precision) { + return DECIMAL.precision(precision); + } + + /** + * The {@link Types#DECIMAL} type. + */ + public static final DataType DECIMAL(int precision, int scale) { + return DECIMAL.precision(precision, scale); + } + // ------------------------------------------------------------------------- // Datetime types // ------------------------------------------------------------------------- @@ -326,21 +410,49 @@ public final class SQLDataType { */ public static final DataType BINARY = new DefaultDataType(null, byte[].class, "binary"); + /** + * The {@link Types#BINARY} type. + */ + public static final DataType BINARY(int length) { + return BINARY.length(length); + } + /** * The {@link Types#VARBINARY} type. */ public static final DataType VARBINARY = new DefaultDataType(null, byte[].class, "varbinary"); + /** + * The {@link Types#VARBINARY} type. + */ + public static final DataType VARBINARY(int length) { + return VARBINARY.length(length); + } + /** * The {@link Types#LONGVARBINARY} type. */ public static final DataType LONGVARBINARY = new DefaultDataType(null, byte[].class, "longvarbinary"); + /** + * The {@link Types#LONGVARBINARY} type. + */ + public static final DataType LONGVARBINARY(int length) { + return LONGVARBINARY.length(length); + } + /** * The {@link Types#BLOB} type. */ public static final DataType BLOB = new DefaultDataType(null, byte[].class, "blob"); + /** + * The {@link Types#BLOB} type. + */ + public static final DataType BLOB(int length) { + return BLOB.length(length); + } + // ------------------------------------------------------------------------- // Other types // -------------------------------------------------------------------------