Package liquibase.common.datatype
Class DataTypeWrapper
- java.lang.Object
-
- liquibase.datatype.LiquibaseDataType
-
- liquibase.common.datatype.DataTypeWrapper
-
- All Implemented Interfaces:
PrioritizedService
public class DataTypeWrapper extends LiquibaseDataType
A wrapper class for data types. Wraps a LiquibaseDataType instance and replaces some of the original data types with dbms-compatible ones.
-
-
Field Summary
-
Fields inherited from interface liquibase.servicelocator.PrioritizedService
COMPARATOR, PRIORITY_DATABASE, PRIORITY_DEFAULT
-
-
Constructor Summary
Constructors Constructor Description DataTypeWrapper(LiquibaseDataType originalType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addParameter(Object value)
Adds an object to the list of this data type's parameters.boolean
equals(Object o)
String[]
getAliases()
LoadDataChange.LOAD_DATA_TYPE
getLoadTypeName()
Returns one of the four basic data types for use in LoadData: BOOLEAN, NUMERIC, DATE or STRINGint
getMaxParameters(Database database)
int
getMinParameters(Database database)
String
getName()
Object[]
getParameters()
Returns an array with the parameters to the data type, e.g.int
getPriority()
LiquibaseDataType
getUnderlyingDataType()
int
hashCode()
String
objectToSql(Object value, Database database)
Returns the value object in a format to include in SQL.Object
stringToObject(String value, Database database)
boolean
supports(Database database)
DatabaseDataType
toDatabaseDataType(Database database)
Transforms this data type into the native data type of the target DBMS.String
toString()
boolean
validate(Database database)
Validates the correct state of this data type against a given database.-
Methods inherited from class liquibase.datatype.LiquibaseDataType
finishInitialization, formatNumber, functionToSql, getAdditionalInformation, getRawDefinition, isAutoIncrement, isCurrentDateTimeFunction, numberToSql, otherToSql, setAdditionalInformation, sqlToObject
-
-
-
-
Constructor Detail
-
DataTypeWrapper
public DataTypeWrapper(LiquibaseDataType originalType)
-
-
Method Detail
-
getUnderlyingDataType
public LiquibaseDataType getUnderlyingDataType()
-
getName
public String getName()
- Overrides:
getName
in classLiquibaseDataType
-
getAliases
public String[] getAliases()
- Overrides:
getAliases
in classLiquibaseDataType
-
getPriority
public int getPriority()
- Specified by:
getPriority
in interfacePrioritizedService
- Overrides:
getPriority
in classLiquibaseDataType
-
supports
public boolean supports(Database database)
- Overrides:
supports
in classLiquibaseDataType
-
getMinParameters
public int getMinParameters(Database database)
- Overrides:
getMinParameters
in classLiquibaseDataType
-
getMaxParameters
public int getMaxParameters(Database database)
- Overrides:
getMaxParameters
in classLiquibaseDataType
-
getParameters
public Object[] getParameters()
Description copied from class:LiquibaseDataType
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.- Overrides:
getParameters
in classLiquibaseDataType
- Returns:
- An array with the parameters. May contain 0 items.
-
addParameter
public void addParameter(Object value)
Description copied from class:LiquibaseDataType
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 untilLiquibaseDataType.validate(Database)
is called, because the number of allowed parameters might differ between DBMS.- Overrides:
addParameter
in classLiquibaseDataType
- Parameters:
value
- the new value to add as parameter.
-
validate
public boolean validate(Database database)
Description copied from class:LiquibaseDataType
Validates the correct state of this data type against a given database.- Overrides:
validate
in classLiquibaseDataType
- Parameters:
database
- the database to validate against- Returns:
- true if the current settings for this data type can be implemented on the given database, false otherwise
-
toDatabaseDataType
public DatabaseDataType toDatabaseDataType(Database database)
Description copied from class:LiquibaseDataType
Transforms this data type into the native data type of the target DBMS.- Overrides:
toDatabaseDataType
in classLiquibaseDataType
- Parameters:
database
- theDatabase
for which the native data type is to be constructed- Returns:
- the new, native data type
-
objectToSql
public String objectToSql(Object value, Database database)
Description copied from class:LiquibaseDataType
Returns the value object in a format to include in SQL. Quote if necessary.- Overrides:
objectToSql
in classLiquibaseDataType
-
toString
public String toString()
- Overrides:
toString
in classLiquibaseDataType
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classLiquibaseDataType
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classLiquibaseDataType
-
getLoadTypeName
public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName()
Description copied from class:LiquibaseDataType
Returns one of the four basic data types for use in LoadData: BOOLEAN, NUMERIC, DATE or STRING- Specified by:
getLoadTypeName
in classLiquibaseDataType
- Returns:
- one of the above Strings
-
-