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 TableEditor
addColumn(Column column)
Add one columns to this table, regardless of theposition
of the supplied columns.TableEditor
addColumns(Column... columns)
Add one or more columns to this table, regardless of theposition
of the supplied columns.TableEditor
addColumns(Iterable<Column> columns)
Add one or more columns to the end of this table's list of columns, regardless of theposition
of 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.Column
columnWithName(String name)
Get the definition for the column in this table with the supplied name.Table
create()
Obtain an immutable table definition representing the current state of this editor.boolean
hasComment()
Determine if acomment
has been set on this table.boolean
hasDefaultCharsetName()
Determine if adefault character set
has been set on this table.default boolean
hasPrimaryKey()
Determine whether this table has a primary key.boolean
hasUniqueValues()
Determine whether this table's primary key contains all columns (viasetUniqueValues()
) such that all rows within the table are unique.static TableEditor
noOp(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.TableEditor
removeColumn(String columnName)
Remove the column with the given name.TableEditor
renameColumn(String existingName, String newName)
Rename the column with the given name to the new specified name.TableEditor
reorderColumn(String columnName, String afterColumnName)
Reorder the column with the given name to be positioned after the designated column.TableEditor
setColumns(Column... columns)
Set this table's column definitions.TableEditor
setColumns(Iterable<Column> columns)
Set this table's column definitions.TableEditor
setComment(String comment)
Set the comment of the tableTableEditor
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.TableEditor
setPrimaryKeyNames(String... pkColumnNames)
Set the columns that make up this table's primary key.TableEditor
setPrimaryKeyNames(List<String> pkColumnNames)
Set the columns that make up this table's primary key.TableEditor
setUniqueValues()
Sets this table's primary key to contain all columns, ensuring that all values are unique within the table.TableId
tableId()
Get the identifier for this table.TableEditor
tableId(TableId tableId)
Set the table identifier.TableEditor
updateColumn(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:
true
if this table has at least oneprimary key column
, orfalse
if there are no primary key columns
-
addColumn
default TableEditor addColumn(Column column)
Add one columns to this table, regardless of theposition
of 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 theposition
of 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 theposition
of 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. IfafterColumnName
is 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 set
has been set on this table.- Returns:
true
if this has a default character set, orfalse
if one has not yet been set
-
hasComment
boolean hasComment()
Determine if acomment
has been set on this table.- Returns:
true
if this has a comment, orfalse
if 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:
true
ifsetUniqueValues()
was last called on this table, orfalse
otherwise
-
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
-
-