Class SqlType

  • All Implemented Interfaces:
    java.lang.Comparable<SqlType>

    public final class SqlType
    extends java.lang.Object
    implements java.lang.Comparable<SqlType>
    A SQL type.
    • Method Detail

      • bool

        public static SqlType bool()
        Returns the BOOL SQL type.
        Returns:
        The BOOL SQL type.
      • bigInt

        public static SqlType bigInt()
        Returns the BIG_INT SQL type.
        Returns:
        The BIG_INT SQL type.
      • smallInt

        public static SqlType smallInt()
        Returns the SMALL_INT SQL type.
        Returns:
        The SMALL_INT SQL type.
      • integer

        public static SqlType integer()
        Returns the INT SQL type.
        Returns:
        The INT SQL type.
      • numeric

        public static SqlType numeric​(int precision,
                                      int scale)
        Returns the NUMERIC SQL type.
        Parameters:
        scale - The scale.
        precision - The precision.
        Returns:
        The NUMERIC SQL type.
      • real

        public static SqlType real()
        Returns the REAL SQL type.
        Returns:
        The REAL SQL type.
      • doublePrecision

        public static SqlType doublePrecision()
        Returns the DOUBLE PRECISION SQL type.
        Returns:
        The DOUBLE PRECISION SQL type.
      • oid

        public static SqlType oid()
        Returns the OID SQL type.
        Returns:
        The OID SQL type.
      • bytes

        public static SqlType bytes()
        Returns the BYTES SQL type.
        Returns:
        The BYTES SQL type.
      • text

        public static SqlType text()
        Returns the TEXT SQL type.
        Returns:
        The TEXT SQL type.
      • varchar

        public static SqlType varchar​(int maxLength)
        Returns the VARCHAR SQL type.
        Parameters:
        maxLength - The maximum length of this VARCHAR type
        Returns:
        The VARCHAR SQL type.
      • character

        public static SqlType character​(int maxLength)
        Returns the CHAR SQL type.
        Parameters:
        maxLength - The maximum length.
        Returns:
        The CHAR SQL type.
      • json

        public static SqlType json()
        Returns the JSON SQL type.
        Returns:
        The JSON SQL type.
      • date

        public static SqlType date()
        Returns the DATE SQL type.
        Returns:
        The DATE SQL type.
      • interval

        public static SqlType interval()
        Returns the INTERVAL SQL type.
        Returns:
        The INTERVAL SQL type.
      • time

        public static SqlType time()
        Returns the TIME SQL type.
        Returns:
        The TIME SQL type.
      • timestamp

        public static SqlType timestamp()
        Returns the TIMESTAMP SQL type.
        Returns:
        The TIMESTAMP SQL type.
      • timestampTz

        public static SqlType timestampTz()
        Returns the TIMESTAMP_TZ SQL type.
        Returns:
        The TIMESTAMP_TZ SQL type.
      • geography

        public static SqlType geography()
        Returns the GEOGRAPHY SQL type.
        Returns:
        The GEOGRAPHY SQL type.
      • getTag

        public TypeTag getTag()
        Returns the type tag.
        Returns:
        The type tag.
      • getInternalOid

        public int getInternalOid()
        Returns the type oid.

        This is an internal method and may go away in future API versions.

        Returns:
        The type oid.
      • getInternalTypeModifier

        public java.util.OptionalInt getInternalTypeModifier()
        Returns the internal type modifier.

        This is an internal method and may go away in future API versions.

        Returns:
        The type modifier.
      • getPrecision

        public java.util.OptionalInt getPrecision()
        Returns the precision if this type is NUMERIC.
        Returns:
        The precision if applicable.
      • getScale

        public java.util.OptionalInt getScale()
        Returns the scale if this type is NUMERIC.
        Returns:
        The scale if applicable.
      • getMaxLength

        public java.util.OptionalInt getMaxLength()
        Returns the maximum length of this type if it is CHAR or VARCHAR.
        Returns:
        The maximum length if applicable.
      • equals

        public boolean equals​(java.lang.Object that)
        Checks two SQL types for equality.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        that - The other SQL type.
        Returns:
        Whether the two SQL types are equal.
      • hashCode

        public int hashCode()
        Computes a hash code.
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(SqlType other)
        Compares this SQL type with the specified SQL type for order.
        Specified by:
        compareTo in interface java.lang.Comparable<SqlType>
        Parameters:
        other - The other SQL type.
        Returns:
        A negative integer, zero, or a positive integer as this SQL type is less than, equal to, or greater than the other SQL type.
      • toString

        public java.lang.String toString()
        Return a string representation of this SQL type that can be used in SQL statements.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The string representation.