Package com.im.commons.db.ddl
Class DBTableInfoImpl
- java.lang.Object
-
- com.im.commons.db.ddl.DBTableInfoImpl
-
- All Implemented Interfaces:
DBTableInfo,java.io.Serializable
public final class DBTableInfoImpl extends java.lang.Object implements DBTableInfo
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.im.commons.db.ddl.DBTableInfo
DBTableInfo.Type
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDBTableInfoImpl()protectedDBTableInfoImpl(DatabasePlatform dbPlatform, DBTableInfo.Type type, java.lang.String schema, java.lang.String tableName, java.lang.String sql, java.util.List<DBColInfo> columns, java.util.List<DBForeignKeyInfo> importedFKInfo, java.util.List<DBForeignKeyInfo> exportedFKInfo, java.util.List<DBConstraintInfo> uniqueConstraints, java.util.List<DBIndexInfo> indexInfo, java.util.List<DBTriggerInfo> triggerInfo, java.util.List<java.lang.String> primaryKeyColumns)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DBTableInfoImplcopy()Creates a duplicate copy of thisDBTableInfoinstance.static DBTableInfoImplcreate(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName, DBTableInfo.Type type, java.util.List<DBColInfo> columns, java.util.List<java.lang.String> primaryKeyColumns, java.lang.String sql)CreatesDBTableInfoinstance with limited information.booleanequals(java.lang.Object obj)DBConstraintInfofindUniqueConstraintNameForColumns(java.lang.String[] columnNames)Retrieves constraint name for the named columns.static DBTableInfoImplforTable(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName, java.util.List<DBColInfo> columns, java.util.List<DBForeignKeyInfo> importedFKInfo, java.util.List<DBForeignKeyInfo> exportedFKInfo, java.util.List<DBConstraintInfo> uniqueConstraints, java.util.List<DBIndexInfo> indexInfo, java.util.List<DBTriggerInfo> triggerInfo, java.util.List<java.lang.String> primaryKeyColumns)static DBTableInfoImplforTableLazy(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName)static DBTableInfoImplforView(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String viewName, java.lang.String sql, java.util.List<DBColInfo> columns)DBColInfogetColumn(java.lang.String columnName)Finds aDBColInfoby its name.java.util.List<DBColInfo>getColumns()Getter for property columns.java.util.List<DBForeignKeyInfo>getExportedFKInfo()Get the foreign keys that involve this table but are defined in a foreign key constraint definition that is defined in another table (though possibly this table).java.util.List<DBForeignKeyInfo>getImportedFKInfo()Get the foreign keys that this table defines.java.util.List<DBIndexInfo>getIndexInfo()java.lang.StringgetName()Gets the name of the database artefact represented by thisDBTableInfo.java.util.List<java.lang.String>getPrimaryKeyColumns()Get the value of primary key columns for the table.java.lang.StringgetSchema()Gets the database schema name of the associated artefact.java.lang.StringgetSQL()Getter for SQL that defines this view if it is a view, otherwise null.java.util.List<DBTriggerInfo>getTriggerInfo()DBTableInfo.TypegetType()Gets the type of thisDBTableInfoinstance.java.util.List<DBConstraintInfo>getUniqueConstraints()inthashCode()booleanisReadOnly()Determines whether this database artifact allows modifications.java.lang.StringschemaPlusTable()Gets the fully qualified name of the underlying database artifact.java.lang.StringtoString()DBTableInfoupdateColumns(java.util.List<DBColInfo> cols)DBTableInfoupdateExportedForeignKeys(java.util.List<DBForeignKeyInfo> fkKeys)DBTableInfoupdateImportedForeignKeys(java.util.List<DBForeignKeyInfo> pkKeys)DBTableInfoupdateIndexInfos(java.util.List<DBIndexInfo> indexes)DBTableInfoupdateUniqueConstraintInfos(java.util.List<DBConstraintInfo> constraints)
-
-
-
Constructor Detail
-
DBTableInfoImpl
protected DBTableInfoImpl()
-
DBTableInfoImpl
protected DBTableInfoImpl(DatabasePlatform dbPlatform, DBTableInfo.Type type, java.lang.String schema, java.lang.String tableName, java.lang.String sql, java.util.List<DBColInfo> columns, java.util.List<DBForeignKeyInfo> importedFKInfo, java.util.List<DBForeignKeyInfo> exportedFKInfo, java.util.List<DBConstraintInfo> uniqueConstraints, java.util.List<DBIndexInfo> indexInfo, java.util.List<DBTriggerInfo> triggerInfo, java.util.List<java.lang.String> primaryKeyColumns)
-
-
Method Detail
-
copy
public DBTableInfoImpl copy()
Description copied from interface:DBTableInfoCreates a duplicate copy of thisDBTableInfoinstance.- Specified by:
copyin interfaceDBTableInfo- Returns:
- A new
DBTableInfoinstance.
-
forTable
public static DBTableInfoImpl forTable(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName, java.util.List<DBColInfo> columns, java.util.List<DBForeignKeyInfo> importedFKInfo, java.util.List<DBForeignKeyInfo> exportedFKInfo, java.util.List<DBConstraintInfo> uniqueConstraints, java.util.List<DBIndexInfo> indexInfo, java.util.List<DBTriggerInfo> triggerInfo, java.util.List<java.lang.String> primaryKeyColumns)
-
forTableLazy
public static DBTableInfoImpl forTableLazy(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName)
-
create
public static DBTableInfoImpl create(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName, DBTableInfo.Type type, java.util.List<DBColInfo> columns, java.util.List<java.lang.String> primaryKeyColumns, java.lang.String sql)
CreatesDBTableInfoinstance with limited information.- Parameters:
dbPlatform- The database platform.schema- The database schema name.tableName- The database table name.type- The type of the createdDBTableInfo.columns- The database table columns.primaryKeyColumns- The columns comprising the primary key.sql- The SQL select statement definingDBTableInfo.Type.VIEWandDBTableInfo.Type.INLINE_VIEW. Can benull.- Returns:
- The new
DBTableInfoinstance. - Since:
- 16.9.26.0
-
forView
public static DBTableInfoImpl forView(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String viewName, java.lang.String sql, java.util.List<DBColInfo> columns)
-
getType
public DBTableInfo.Type getType()
Description copied from interface:DBTableInfoGets the type of thisDBTableInfoinstance.- Specified by:
getTypein interfaceDBTableInfo- Returns:
- This
DBTableInfo's type.
-
getSchema
public java.lang.String getSchema()
Description copied from interface:DBTableInfoGets the database schema name of the associated artefact.- Specified by:
getSchemain interfaceDBTableInfo- Returns:
- The schema this item belongs to.
-
getName
public java.lang.String getName()
Description copied from interface:DBTableInfoGets the name of the database artefact represented by thisDBTableInfo.- Specified by:
getNamein interfaceDBTableInfo- Returns:
- The name.
-
schemaPlusTable
public java.lang.String schemaPlusTable()
Description copied from interface:DBTableInfoGets the fully qualified name of the underlying database artifact.- Specified by:
schemaPlusTablein interfaceDBTableInfo- Returns:
- The concatenated form of
DBTableInfo.getName()andDBTableInfo.getSchema().
-
getSQL
public java.lang.String getSQL()
Getter for SQL that defines this view if it is a view, otherwise null.- Specified by:
getSQLin interfaceDBTableInfo- Returns:
- Value of property sql.
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:DBTableInfoDetermines whether this database artifact allows modifications.- Specified by:
isReadOnlyin interfaceDBTableInfo- Returns:
trueif this database artifact is readonly and cannot be modified.
-
getColumn
public DBColInfo getColumn(java.lang.String columnName)
Description copied from interface:DBTableInfoFinds aDBColInfoby its name. This will search through the columns in thisDBTableInfofor a column with the required name.- Specified by:
getColumnin interfaceDBTableInfo- Parameters:
columnName- The name of the column to find.- Returns:
- The
DBColInfowith the required name ornullif no such column exists.
-
getColumns
public java.util.List<DBColInfo> getColumns()
Getter for property columns.- Specified by:
getColumnsin interfaceDBTableInfo- Returns:
- Value of property columns.
-
updateColumns
public DBTableInfo updateColumns(java.util.List<DBColInfo> cols)
- Specified by:
updateColumnsin interfaceDBTableInfo
-
findUniqueConstraintNameForColumns
public DBConstraintInfo findUniqueConstraintNameForColumns(java.lang.String[] columnNames)
Retrieves constraint name for the named columns. The method will return name of the unique constraint for the given set of columns. The constraint name may beDatabasePlatform.NAME_PRIMARY_KEY_CONSTRAINT, which may be handled differently in some databases - for drop, useDatabasePlatform.sqlDropPrimaryConstraint(String, String, String[]).- Specified by:
findUniqueConstraintNameForColumnsin interfaceDBTableInfo- Parameters:
columnNames- DB columns- Returns:
- The constraint, or
nullif there's no unique constraint.
-
getImportedFKInfo
public java.util.List<DBForeignKeyInfo> getImportedFKInfo()
Get the foreign keys that this table defines. e.g. the primary keys of other tables (or possibly this table) that are referred to in a foreign key constraint definition.- Specified by:
getImportedFKInfoin interfaceDBTableInfo- Returns:
- A list of foreign keys
-
getExportedFKInfo
public java.util.List<DBForeignKeyInfo> getExportedFKInfo()
Get the foreign keys that involve this table but are defined in a foreign key constraint definition that is defined in another table (though possibly this table). e.g. the keys in this table that are referred to in a foreign key constraint definition somewhere.- Specified by:
getExportedFKInfoin interfaceDBTableInfo- Returns:
- A list of foreign keys
-
getUniqueConstraints
public java.util.List<DBConstraintInfo> getUniqueConstraints()
- Specified by:
getUniqueConstraintsin interfaceDBTableInfo
-
updateUniqueConstraintInfos
public DBTableInfo updateUniqueConstraintInfos(java.util.List<DBConstraintInfo> constraints)
- Specified by:
updateUniqueConstraintInfosin interfaceDBTableInfo
-
updateImportedForeignKeys
public DBTableInfo updateImportedForeignKeys(java.util.List<DBForeignKeyInfo> pkKeys)
- Specified by:
updateImportedForeignKeysin interfaceDBTableInfo
-
updateExportedForeignKeys
public DBTableInfo updateExportedForeignKeys(java.util.List<DBForeignKeyInfo> fkKeys)
- Specified by:
updateExportedForeignKeysin interfaceDBTableInfo
-
getIndexInfo
public java.util.List<DBIndexInfo> getIndexInfo()
- Specified by:
getIndexInfoin interfaceDBTableInfo
-
updateIndexInfos
public DBTableInfo updateIndexInfos(java.util.List<DBIndexInfo> indexes)
- Specified by:
updateIndexInfosin interfaceDBTableInfo
-
getPrimaryKeyColumns
public java.util.List<java.lang.String> getPrimaryKeyColumns()
Get the value of primary key columns for the table.- Specified by:
getPrimaryKeyColumnsin interfaceDBTableInfo- Returns:
- The primary key columns for the table in the order that they are defined
-
getTriggerInfo
public java.util.List<DBTriggerInfo> getTriggerInfo()
- Specified by:
getTriggerInfoin interfaceDBTableInfo
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-