Package io.debezium.relational
Interface TableEditor
-
- All Known Implementing Classes:
NoOpTableEditorImpl,TableEditorImpl
@NotThreadSafe public interface TableEditor
- Author:
- Randall Hauch
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default TableEditoraddColumn(Column column)Add one columns to this table, regardless of thepositionof the supplied columns.TableEditoraddColumns(Column... columns)Add one or more columns to this table, regardless of thepositionof the supplied columns.TableEditoraddColumns(Iterable<Column> columns)Add one or more columns to the end of this table's list of columns, regardless of thepositionof the supplied columns.default List<String>columnNames()Get the names of the columns in this table.List<Column>columns()Get the definitions for the columns in this table.ColumncolumnWithName(String name)Get the definition for the column in this table with the supplied name.Tablecreate()Obtain an immutable table definition representing the current state of this editor.booleanhasComment()Determine if acommenthas been set on this table.booleanhasDefaultCharsetName()Determine if adefault character sethas been set on this table.default booleanhasPrimaryKey()Determine whether this table has a primary key.booleanhasUniqueValues()Determine whether this table's primary key contains all columns (viasetUniqueValues()) such that all rows within the table are unique.static TableEditornoOp(TableId id)Create a new editor that does nothing.List<String>primaryKeyColumnNames()The list of column names that make up the primary key for this table.TableEditorremoveColumn(String columnName)Remove the column with the given name.TableEditorrenameColumn(String existingName, String newName)Rename the column with the given name to the new specified name.TableEditorreorderColumn(String columnName, String afterColumnName)Reorder the column with the given name to be positioned after the designated column.TableEditorsetColumns(Column... columns)Set this table's column definitions.TableEditorsetColumns(Iterable<Column> columns)Set this table's column definitions.TableEditorsetComment(String comment)Set the comment of the tableTableEditorsetDefaultCharsetName(String charsetName)Set the name of the character set that should be used by default in the columns that require a character set but have not defined one.TableEditorsetPrimaryKeyNames(String... pkColumnNames)Set the columns that make up this table's primary key.TableEditorsetPrimaryKeyNames(List<String> pkColumnNames)Set the columns that make up this table's primary key.TableEditorsetUniqueValues()Sets this table's primary key to contain all columns, ensuring that all values are unique within the table.TableIdtableId()Get the identifier for this table.TableEditortableId(TableId tableId)Set the table identifier.TableEditorupdateColumn(Column column)Update the column with the given name.
-
-
-
Method Detail
-
noOp
static TableEditor noOp(TableId id)
Create a new editor that does nothing.- Parameters:
id- the table's identifier; may not be null- Returns:
- the editor; never null
-
tableId
TableId tableId()
Get the identifier for this table.- Returns:
- the table identifier; may be null if not set
-
tableId
TableEditor tableId(TableId tableId)
Set the table identifier.- Parameters:
tableId- the table identifier- Returns:
- this editor so callers can chain methods together
-
columns
List<Column> columns()
Get the definitions for the columns in this table. The resulting list should not be modified directly; instead, the column definitions should be defined withaddColumns(Column...),addColumns(Iterable),setColumns(Column...),setColumns(Iterable), orremoveColumn(String).- Returns:
- the ordered list of definitions; never null
-
columnNames
default List<String> columnNames()
Get the names of the columns in this table. The resulting list should not be modified directly; instead, the column definitions should be defined withaddColumns(Column...),addColumns(Iterable),setColumns(Column...),setColumns(Iterable), orremoveColumn(String).- Returns:
- the ordered list of column names; never null
-
columnWithName
Column columnWithName(String name)
Get the definition for the column in this table with the supplied name. The case of the supplied name does not matter.- Parameters:
name- the case-insensitive name of the column- Returns:
- the column definition, or null if there is no column with the given name
-
primaryKeyColumnNames
List<String> primaryKeyColumnNames()
The list of column names that make up the primary key for this table. The resulting list should not be modified directly; instead, the set of primary key names should be defined withsetPrimaryKeyNames(String...).- Returns:
- the list of column names that make up the primary key; never null but possibly empty
-
hasPrimaryKey
default boolean hasPrimaryKey()
Determine whether this table has a primary key.- Returns:
trueif this table has at least oneprimary key column, orfalseif there are no primary key columns
-
addColumn
default TableEditor addColumn(Column column)
Add one columns to this table, regardless of thepositionof the supplied columns. However, if an existing column definition matches a supplied column, the new column definition will replace the existing column definition.- Parameters:
column- the definition for the column to be added- Returns:
- this editor so callers can chain methods together
-
addColumns
TableEditor addColumns(Column... columns)
Add one or more columns to this table, regardless of thepositionof the supplied columns. However, if an existing column definition matches a supplied column, the new column definition will replace the existing column definition.- Parameters:
columns- the definitions for the columns to be added- Returns:
- this editor so callers can chain methods together
-
addColumns
TableEditor addColumns(Iterable<Column> columns)
Add one or more columns to the end of this table's list of columns, regardless of thepositionof the supplied columns. However, if an existing column definition matches a supplied column, the new column definition will replace the existing column definition.- Parameters:
columns- the definitions for the columns to be added- Returns:
- this editor so callers can chain methods together
-
setColumns
TableEditor setColumns(Column... columns)
Set this table's column definitions. The table's primary key columns may be removed as a result of this method if they refer to columns that are not in the supplied list of column definitions.- Parameters:
columns- the definitions for the columns to be added- Returns:
- this editor so callers can chain methods together
-
setColumns
TableEditor setColumns(Iterable<Column> columns)
Set this table's column definitions. The table's primary key columns may be removed as a result of this method if they refer to columns that are not in the supplied list of column definitions.- Parameters:
columns- the definitions for the columns to be added- Returns:
- this editor so callers can chain methods together
-
removeColumn
TableEditor removeColumn(String columnName)
Remove the column with the given name. This method does nothing if no such column exists.- Parameters:
columnName- the name of the column to be removed- Returns:
- this editor so callers can chain methods together
-
updateColumn
TableEditor updateColumn(Column column)
Update the column with the given name. The existing column definition with the name as the column provided is replaced with the new one.- Parameters:
column- the new column definition- Returns:
- this editor so callers can chain methods together
-
reorderColumn
TableEditor reorderColumn(String columnName, String afterColumnName)
Reorder the column with the given name to be positioned after the designated column. IfafterColumnNameis null, the column will be moved to the first column.- Parameters:
columnName- the name of the column to be removedafterColumnName- the name of the column after which the moved column is to be positioned; may be null if the column is to be moved to the first column- Returns:
- this editor so callers can chain methods together
-
renameColumn
TableEditor renameColumn(String existingName, String newName)
Rename the column with the given name to the new specified name.- Parameters:
existingName- the existing name of the column to be renamed; may not be nullnewName- the new name of the column; may not be null- Returns:
- this editor so callers can chain methods together
-
setPrimaryKeyNames
TableEditor setPrimaryKeyNames(String... pkColumnNames)
Set the columns that make up this table's primary key.- Parameters:
pkColumnNames- the names of this tables columns that make up the primary key- Returns:
- this editor so callers can chain methods together
- Throws:
IllegalArgumentException- if a name does not correspond to an existing column
-
setPrimaryKeyNames
TableEditor setPrimaryKeyNames(List<String> pkColumnNames)
Set the columns that make up this table's primary key.- Parameters:
pkColumnNames- the names of this tables columns that make up the primary key- Returns:
- this editor so callers can chain methods together
- Throws:
IllegalArgumentException- if a name does not correspond to an existing column
-
setUniqueValues
TableEditor setUniqueValues()
Sets this table's primary key to contain all columns, ensuring that all values are unique within the table. This is analogous to callingsetPrimaryKeyNames(columnNames())except that the primary key is updated when columns are added or removed.- Returns:
- this editor so callers can chain methods together
- Throws:
IllegalArgumentException- if a name does not correspond to an existing column
-
setDefaultCharsetName
TableEditor setDefaultCharsetName(String charsetName)
Set the name of the character set that should be used by default in the columns that require a character set but have not defined one.- Parameters:
charsetName- the name of the character set that should be used by default- Returns:
- this editor so callers can chain methods together
-
setComment
TableEditor setComment(String comment)
Set the comment of the table- Parameters:
comment- table comment- Returns:
- this editor so callers can chain methods together
-
hasDefaultCharsetName
boolean hasDefaultCharsetName()
Determine if adefault character sethas been set on this table.- Returns:
trueif this has a default character set, orfalseif one has not yet been set
-
hasComment
boolean hasComment()
Determine if acommenthas been set on this table.- Returns:
trueif this has a comment, orfalseif one has not yet been set
-
hasUniqueValues
boolean hasUniqueValues()
Determine whether this table's primary key contains all columns (viasetUniqueValues()) such that all rows within the table are unique.- Returns:
trueifsetUniqueValues()was last called on this table, orfalseotherwise
-
create
Table create()
Obtain an immutable table definition representing the current state of this editor. This editor can be reused after this method, since the resulting table definition no longer refers to any of the data used in this editor.- Returns:
- the immutable table definition; never null
-
-