diff --git a/jOOQ/src/main/java/org/jooq/DataType.java b/jOOQ/src/main/java/org/jooq/DataType.java index ce2fcfcb6e..1802f68502 100644 --- a/jOOQ/src/main/java/org/jooq/DataType.java +++ b/jOOQ/src/main/java/org/jooq/DataType.java @@ -233,6 +233,17 @@ public interface DataType extends Serializable { */ boolean nullable(); + /** + * Return a new data type like this, with a new collation. + */ + DataType collation(Collation collation); + + /** + * Get the collation of this data type, or null if there is no + * collation, or if the default collation applies. + */ + Collation collation(); + /** * Return a new data type like this, with a new identity flag. *

diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java index 3fb8419e5c..17a14182cd 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java @@ -63,6 +63,7 @@ import java.util.regex.Pattern; // ... import org.jooq.Binding; +import org.jooq.Collation; import org.jooq.Configuration; import org.jooq.Converter; import org.jooq.DataType; @@ -212,6 +213,7 @@ public class DefaultDataType implements DataType { private final String typeName; private final Nullability nullability; + private final Collation collation; private final boolean identity; private final Field defaultValue; private final int precision; @@ -267,10 +269,10 @@ public class DefaultDataType implements DataType { } DefaultDataType(SQLDialect dialect, DataType sqlDataType, Class type, Binding binding, String typeName, String castTypeName, int precision, int scale, int length, Nullability nullability, Field defaultValue) { - this(dialect, sqlDataType, type, binding, typeName, castTypeName, precision, scale, length, nullability, false, defaultValue); + this(dialect, sqlDataType, type, binding, typeName, castTypeName, precision, scale, length, nullability, null, false, defaultValue); } - DefaultDataType(SQLDialect dialect, DataType sqlDataType, Class type, Binding binding, String typeName, String castTypeName, int precision, int scale, int length, Nullability nullability, boolean identity, Field defaultValue) { + DefaultDataType(SQLDialect dialect, DataType sqlDataType, Class type, Binding binding, String typeName, String castTypeName, int precision, int scale, int length, Nullability nullability, Collation collation, boolean identity, Field defaultValue) { // Initialise final instance members // --------------------------------- @@ -286,6 +288,7 @@ public class DefaultDataType implements DataType { this.arrayType = (Class) Array.newInstance(type, 0).getClass(); this.nullability = nullability; + this.collation = collation; this.identity = identity; this.defaultValue = defaultValue; this.precision = precision0(type, precision); @@ -329,7 +332,7 @@ public class DefaultDataType implements DataType { /** * [#3225] Performant constructor for creating derived types. */ - private DefaultDataType(DefaultDataType t, int precision, int scale, int length, Nullability nullability, boolean identity, Field defaultValue) { + private DefaultDataType(DefaultDataType t, int precision, int scale, int length, Nullability nullability, Collation collation, boolean identity, Field defaultValue) { this.dialect = t.dialect; this.sqlDataType = t.sqlDataType; this.uType = t.uType; @@ -340,6 +343,7 @@ public class DefaultDataType implements DataType { this.arrayType = t.arrayType; this.nullability = nullability; + this.collation = collation; this.identity = identity; this.defaultValue = defaultValue; this.precision = precision0(uType, precision); @@ -370,7 +374,7 @@ public class DefaultDataType implements DataType { @Override public final DataType nullability(Nullability n) { - return new DefaultDataType(this, precision, scale, length, n, n.nullable() ? false : identity, defaultValue); + return new DefaultDataType(this, precision, scale, length, n, collation, n.nullable() ? false : identity, defaultValue); } @Override @@ -388,9 +392,19 @@ public class DefaultDataType implements DataType { return nullability.nullable(); } + @Override + public final DataType collation(Collation c) { + return new DefaultDataType(this, precision, scale, length, nullability, c, identity, defaultValue); + } + + @Override + public final Collation collation() { + return collation; + } + @Override public final DataType identity(boolean i) { - return new DefaultDataType(this, precision, scale, length, i ? NOT_NULL : nullability, i, i ? null : defaultValue); + return new DefaultDataType(this, precision, scale, length, i ? NOT_NULL : nullability, collation, i, i ? null : defaultValue); } @Override @@ -405,7 +419,7 @@ public class DefaultDataType implements DataType { @Override public final DataType defaultValue(Field d) { - return new DefaultDataType(this, precision, scale, length, nullability, d != null ? false : identity, d); + return new DefaultDataType(this, precision, scale, length, nullability, collation, d != null ? false : identity, d); } @Override @@ -438,7 +452,7 @@ public class DefaultDataType implements DataType { else if (isLob()) return this; else - return new DefaultDataType(this, p, s, length, nullability, identity, defaultValue); + return new DefaultDataType(this, p, s, length, nullability, collation, identity, defaultValue); } @Override @@ -468,7 +482,7 @@ public class DefaultDataType implements DataType { if (isLob()) return this; else - return new DefaultDataType(this, precision, s, length, nullability, identity, defaultValue); + return new DefaultDataType(this, precision, s, length, nullability, collation, identity, defaultValue); } @Override @@ -490,7 +504,7 @@ public class DefaultDataType implements DataType { if (isLob()) return this; else - return new DefaultDataType(this, precision, scale, l, nullability, identity, defaultValue); + return new DefaultDataType(this, precision, scale, l, nullability, collation, identity, defaultValue); } @Override