Class LiquibaseDataType

All Implemented Interfaces:
Direct Known Subclasses:
BigIntType, BinaryTypeSnowflake, BlobType, BooleanType, CharType, ClobType, ClobTypeSnowflake, CurrencyType, DatabaseFunctionType, DataTypeWrapper, DateTimeType, DateType, DecimalType, DoubleType, FloatType, IntType, MediumIntType, NumberType, SmallIntType, TextDataTypeSnowflake, TimestampNTZTypeSnowflake, TimeType, TinyIntType, UnknownType, UUIDType, XMLType

public abstract class LiquibaseDataType extends Object implements PrioritizedService
Object representing a data type, instead of a plain string. It will be returned by the getXXXType in the Database interface.
  • Constructor Details

    • LiquibaseDataType

      protected LiquibaseDataType(LiquibaseDataType originalType)
    • LiquibaseDataType

      public LiquibaseDataType()
    • LiquibaseDataType

      protected LiquibaseDataType(String name, int minParameters, int maxParameters)
  • Method Details

    • getName

      public String getName()
    • getAliases

      public String[] getAliases()
    • getPriority

      public int getPriority()
      Specified by:
      getPriority in interface PrioritizedService
    • supports

      public boolean supports(Database database)
    • getMinParameters

      public int getMinParameters(Database database)
    • getMaxParameters

      public int getMaxParameters(Database database)
    • getParameters

      public Object[] getParameters()
      Returns an array with the parameters to the data type, e.g. NUMBER(10, 2) would return an array with the items 10 and 2.
      An array with the parameters. May contain 0 items.
    • addParameter

      public void addParameter(Object value)
      Adds an object to the list of this data type's parameters. Note that it is possible to temporarily exceed the allowed number of allowed parameters until validate(Database) is called, because the number of allowed parameters might differ between DBMS.
      value - the new value to add as parameter.
    • getAdditionalInformation

      public String getAdditionalInformation()
      Returns additional information that was stored during DataTypeFactory.fromDescription(String, Database) or other parsers.
      the additional information. Might be null.
    • setAdditionalInformation

      public void setAdditionalInformation(String additionalInformation)
    • getRawDefinition

      public String getRawDefinition()
      Obtains the "raw" data type definition if one was used to create this object as a result of parsing
      the raw definition, or null.
    • validate

      public boolean validate(Database database)
      Validates the correct state of this data type against a given database.
      database - the database to validate against
      true if the current settings for this data type can be implemented on the given database, false otherwise
    • toDatabaseDataType

      public DatabaseDataType toDatabaseDataType(Database database)
      Transforms this data type into the native data type of the target DBMS.
      database - the Database for which the native data type is to be constructed
      the new, native data type
    • objectToSql

      public String objectToSql(Object value, Database database)
      Returns the value object in a format to include in SQL. Quote if necessary.
    • functionToSql

      protected String functionToSql(DatabaseFunction function, Database database)
    • numberToSql

      protected String numberToSql(Number number, Database database)
    • otherToSql

      protected String otherToSql(Object value, Database database)
    • sqlToObject

      public Object sqlToObject(String value, Database database)
    • toString

      public String toString()
      toString in class Object
    • equals

      public boolean equals(Object o)
      equals in class Object
    • hashCode

      public int hashCode()
      hashCode in class Object
    • isCurrentDateTimeFunction

      protected boolean isCurrentDateTimeFunction(String string, Database database)
      Determines if the given function name refers to the function that returns the current time and date for a specific DBMS. Also returns true if the name returns the Liquibase wildcard CURRENT_DATE_TIME_PLACE_HOLDER, which will later be translated into the appropriate function.
      string - The database function name to test
      database - A database object to test against
      see above
    • finishInitialization

      public void finishInitialization(String originalDefinition)
    • formatNumber

      protected String formatNumber(String value)
      Removes any trailing ".0[...]0" from the end of a number
      value - the number (in String form) to format
      the formatted number
    • getLoadTypeName

      public abstract LoadDataChange.LOAD_DATA_TYPE getLoadTypeName()
      Returns one of the four basic data types for use in LoadData: BOOLEAN, NUMERIC, DATE or STRING
      one of the above Strings
    • isAutoIncrement

      public boolean isAutoIncrement()