/** * Constructs a type with nullablity */ BasicSqlType createWithNullability(boolean nullable) { BasicSqlType ret; try { ret = (BasicSqlType) this.clone(); } catch (CloneNotSupportedException e) { throw new AssertionError(e); } ret.isNullable = nullable; ret.computeDigest(); return ret; }
/** * Constructs a type with precision/length but no scale. * * @param typeName Type name */ public BasicSqlType(RelDataTypeSystem typeSystem, SqlTypeName typeName, int precision) { this(typeSystem, typeName, false, precision, SCALE_NOT_SPECIFIED); assert typeName.allowsPrecScale(true, false) : "typeName.allowsPrecScale(true, false)"; computeDigest(); }
/** * Constructs a type with precision/length and scale. * * @param typeName Type name */ public BasicSqlType(RelDataTypeSystem typeSystem, SqlTypeName typeName, int precision, int scale) { this(typeSystem, typeName, false, precision, scale); assert typeName.allowsPrecScale(true, true); computeDigest(); }
/** Internal constructor. */ private BasicSqlType( RelDataTypeSystem typeSystem, SqlTypeName typeName, boolean nullable, int precision, int scale, SqlCollation collation, SerializableCharset wrappedCharset) { super(typeName, nullable, null); this.typeSystem = Objects.requireNonNull(typeSystem); this.precision = precision; this.scale = scale; this.collation = collation; this.wrappedCharset = wrappedCharset; computeDigest(); }
/** * Constructs a type with charset and collation. * * <p>This must be a character tyoe. */ BasicSqlType createWithCharsetAndCollation( Charset charset, SqlCollation collation) { Preconditions.checkArgument(SqlTypeUtil.inCharFamily(this)); BasicSqlType ret; try { ret = (BasicSqlType) this.clone(); } catch (CloneNotSupportedException e) { throw new AssertionError(e); } ret.wrappedCharset = SerializableCharset.forCharset(charset); ret.collation = collation; ret.computeDigest(); return ret; }
/** * Constructs a type with no parameters. This should only be called from a * factory method. * * @param typeName Type name */ public BasicSqlType(RelDataTypeSystem typeSystem, SqlTypeName typeName) { this(typeSystem, typeName, false, PRECISION_NOT_SPECIFIED, SCALE_NOT_SPECIFIED); assert typeName.allowsPrecScale(false, false) : "typeName.allowsPrecScale(false,false), typeName=" + typeName.name(); computeDigest(); }