Class ForeignKey

java.lang.Object
io.github.mfvanek.pg.model.constraint.ForeignKey
All Implemented Interfaces:
DbObject, TableNameAware

@Immutable public class ForeignKey extends Object implements DbObject, TableNameAware
A representation of foreign key in a database.
See Also:
  • Method Details

    • getName

      @Nonnull public final String getName()
      Gets database object name.
      Specified by:
      getName in interface DbObject
      Returns:
      database object name
    • getTableName

      @Nonnull public String getTableName()
      Gets table name.
      Specified by:
      getTableName in interface TableNameAware
      Returns:
      table name
    • getConstraintName

      @Nonnull public String getConstraintName()
      Gets the name of foreign key constraint.
      Returns:
      the name of foreign key
    • getColumnsInConstraint

      @Nonnull public List<Column> getColumnsInConstraint()
      Gets columns of foreign key constraint.
      Returns:
      columns of foreign key constraint
      See Also:
    • equals

      public final boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object
    • of

      @Nonnull public static ForeignKey of(@Nonnull String tableName, @Nonnull String constraintName, @Nonnull List<Column> columnsInConstraint)
      Constructs a ForeignKey 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 a ForeignKey object with given Column.
      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 a ForeignKey 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 a ForeignKey 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