java.lang.Object
org.litebridge.db.spi.ColumnMetaData
- All Implemented Interfaces:
MappedFieldTarget
Metadata information for a database column.
This class extends the functionality of the Column class to include additional attributes
typically associated with database column metadata, such as nullability, data type, size, and others.
Instances of this class are immutable except for specific mutable fields like auto-increment, sequence, and joinColumn, which can be modified after initialization.
-
Constructor Summary
ConstructorsConstructorDescriptionColumnMetaData(Table table, String name, boolean nullable, int dataType) Construct an instance ofColumnMetaDatawith specified metadata details about a database column.ColumnMetaData(Table table, String name, boolean nullable, int dataType, int size) Construct an instance ofColumnMetaDatawith specified metadata details about a database column.ColumnMetaData(Table table, String name, boolean nullable, int dataType, int size, int decimalDigits, boolean autoIncrement, @Nullable ColumnValueGenerator generator) Construct an instance ofColumnMetaDatawith specified metadata details about a database column. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddForeignKeyConstraint(ForeignKeyConstraint foreignKeyConstraint) Adds a foreign key constraint to this column.voidaddForeignReference(ForeignKeyConstraint foreignKeyConstraint) Adds a foreign reference to this column.booleanintRetrieve the data type of the column, as specified inTypes.intRetrieve the number of decimal digits for the column.Gets all foreign key constraints associated with this column.Gets all foreign references associated with this column.@Nullable ColumnValueGeneratorGets the value generator for this column.@Nullable StringGets the name of the join column, if applicable.intgetSize()Retrieve the size of the column.inthashCode()booleanCheck if the column's value is automatically incremented by the database.booleanDetermine if the column allows null values.name()Gets the name of the column.voidsetAutoIncrement(boolean autoIncrement) Sets whether this column is an auto-increment column.voidsetGenerator(@Nullable ColumnValueGenerator generator) Sets the value generator for this column.voidsetJoinColumn(@Nullable String joinColumn) Sets the name of the join column.table()Gets the table this column belongs to.toColumn()Converts this metadata into aColumninstance.toString()
-
Constructor Details
-
ColumnMetaData
public ColumnMetaData(Table table, String name, boolean nullable, int dataType, int size, int decimalDigits, boolean autoIncrement, @Nullable ColumnValueGenerator generator) Construct an instance ofColumnMetaDatawith specified metadata details about a database column.- Parameters:
table- the table to which this column belongs; must not be nullname- the name of the column; must not be nullnullable- a flag indicating whether the column allows null valuesdataType- the SQL data type of the column as defined inTypessize- the size of the column, typically representing the maximum number of characters for string or digits for numeric typesdecimalDigits- the number of decimal digits for the column, applicable for numeric typesautoIncrement- a flag indicating whether the column is defined as auto-incrementgenerator- the name of the sequence associated with the column, or null if no sequence is associated
-
ColumnMetaData
Construct an instance ofColumnMetaDatawith specified metadata details about a database column.Sets
decimalDigitsto0,autoIncrementtofalse, andsequencetonull.- Parameters:
table- the table to which this column belongs; must not be nullname- the name of the column; must not be nullnullable- a flag indicating whether the column allows null valuesdataType- the SQL data type of the column as defined inTypessize- the size of the column, typically representing the maximum number of characters for string or digits for numeric types
-
ColumnMetaData
Construct an instance ofColumnMetaDatawith specified metadata details about a database column.Sets
decimalDigitsandsizeto0,autoIncrementtofalse, andsequencetonull.- Parameters:
table- the table to which this column belongs; must not be nullname- the name of the column; must not be nullnullable- a flag indicating whether the column allows null valuesdataType- the SQL data type of the column as defined inTypes
-
-
Method Details
-
name
Gets the name of the column.- Returns:
- the column name
-
table
Gets the table this column belongs to.- Returns:
- the table
-
isNullable
public boolean isNullable()Determine if the column allows null values.- Returns:
trueif the column allows null values, otherwisefalse.
-
getDataType
public int getDataType()Retrieve the data type of the column, as specified inTypes.- Returns:
- the SQL data type.
- See Also:
-
getSize
public int getSize()Retrieve the size of the column.- Returns:
- the size of the column.
-
getDecimalDigits
public int getDecimalDigits()Retrieve the number of decimal digits for the column.- Returns:
- the number of decimal digits specified for the column.
-
isAutoIncrement
public boolean isAutoIncrement()Check if the column's value is automatically incremented by the database.- Returns:
trueif the column is marked as auto-increment,falseotherwise.
-
setAutoIncrement
public void setAutoIncrement(boolean autoIncrement) Sets whether this column is an auto-increment column.- Parameters:
autoIncrement-trueif auto-increment;falseotherwise
-
getGenerator
Gets the value generator for this column.- Returns:
- the value generator, or
nullif none
-
setGenerator
Sets the value generator for this column.- Parameters:
generator- the value generator to set
-
getJoinColumn
Gets the name of the join column, if applicable.- Returns:
- the join column name
-
setJoinColumn
Sets the name of the join column.- Parameters:
joinColumn- the join column name to set
-
addForeignKeyConstraint
Adds a foreign key constraint to this column.- Parameters:
foreignKeyConstraint- the constraint to add
-
getForeignKeyConstraints
Gets all foreign key constraints associated with this column.- Returns:
- the list of foreign key constraints
-
addForeignReference
Adds a foreign reference to this column.- Parameters:
foreignKeyConstraint- the reference to add
-
getForeignReferences
Gets all foreign references associated with this column.- Returns:
- the list of foreign references
-
toColumn
Converts this metadata into aColumninstance.- Returns:
- a new
Columninstance
-
equals
-
hashCode
public int hashCode() -
toString
-