Class ForeignKey
java.lang.Object
io.github.mfvanek.pg.model.constraint.ForeignKey
- All Implemented Interfaces:
DbObject
,TableNameAware
A representation of foreign key in a database.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Gets columns of foreign key constraint.Gets the name of foreign key constraint.final String
getName()
Gets database object name.Gets table name.final int
hashCode()
static ForeignKey
Constructs aForeignKey
object with given columns.static ForeignKey
Constructs aForeignKey
object with givenColumn
.static ForeignKey
ofNotNullColumn
(String tableName, String constraintName, String columnName) Constructs aForeignKey
object with not null column.static ForeignKey
ofNullableColumn
(String tableName, String constraintName, String columnName) Constructs aForeignKey
object with nullable column.toString()
-
Method Details
-
getName
Gets database object name. -
getTableName
Gets table name.- Specified by:
getTableName
in interfaceTableNameAware
- Returns:
- table name
-
getConstraintName
Gets the name of foreign key constraint.- Returns:
- the name of foreign key
-
getColumnsInConstraint
Gets columns of foreign key constraint.- Returns:
- columns of foreign key constraint
- See Also:
-
equals
-
hashCode
public final int hashCode() -
toString
-
of
@Nonnull public static ForeignKey of(@Nonnull String tableName, @Nonnull String constraintName, @Nonnull List<Column> columnsInConstraint) Constructs aForeignKey
object with given columns.- Parameters:
tableName
- table name; should be non-blank.constraintName
- constraint name; should be non-blank.columnsInConstraint
- list of columns that are included in constraint; should be non-empty.- Returns:
ForeignKey
-
ofColumn
@Nonnull public static ForeignKey ofColumn(@Nonnull String tableName, @Nonnull String constraintName, @Nonnull Column column) Constructs aForeignKey
object with givenColumn
.- Parameters:
tableName
- table name; should be non-blank.constraintName
- constraint name; should be non-blank.column
- column that is included in constraint.- Returns:
ForeignKey
-
ofNotNullColumn
@Nonnull public static ForeignKey ofNotNullColumn(@Nonnull String tableName, @Nonnull String constraintName, @Nonnull String columnName) Constructs aForeignKey
object with not null column.- Parameters:
tableName
- table name; should be non-blank.constraintName
- constraint name; should be non-blank.columnName
- name of column that is included in constraint; should be non-blank.- Returns:
ForeignKey
-
ofNullableColumn
@Nonnull public static ForeignKey ofNullableColumn(@Nonnull String tableName, @Nonnull String constraintName, @Nonnull String columnName) Constructs aForeignKey
object with nullable column.- Parameters:
tableName
- table name; should be non-blank.constraintName
- constraint name; should be non-blank.columnName
- name of column that is included in constraint; should be non-blank.- Returns:
ForeignKey
-