Class Constraint
java.lang.Object
io.github.mfvanek.pg.model.constraint.Constraint
- All Implemented Interfaces:
DbObject,TableNameAware
- Direct Known Subclasses:
ForeignKey
A representation of constraint in a database.
- Since:
- 0.11.0
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstraint(String tableName, String constraintName, ConstraintType constraintType) Constructs aConstraintobject with givenConstraintType. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanGets the name of constraint.Gets type of constraint.final StringgetName()Gets database object name.final PgObjectTypeGets database object type.Gets table name.Builds and returns sql query to validate current constraint.final inthashCode()static ConstraintofType(String tableName, String constraintName, ConstraintType constraintType) Constructs aConstraintobject with givenConstraintType.toString()
-
Constructor Details
-
Constraint
protected Constraint(@Nonnull String tableName, @Nonnull String constraintName, @Nonnull ConstraintType constraintType) Constructs aConstraintobject with givenConstraintType.- Parameters:
tableName- table name; should be non-blank.constraintName- constraint name; should be non-blank.constraintType- constraint type; should be non-null.
-
-
Method Details
-
getName
Gets database object name. -
getObjectType
Gets database object type.- Specified by:
getObjectTypein interfaceDbObject- Returns:
- database object type
-
getTableName
Gets table name.- Specified by:
getTableNamein interfaceTableNameAware- Returns:
- table name
-
getConstraintName
Gets the name of constraint.- Returns:
- the name of constraint
-
getConstraintType
Gets type of constraint.- Returns:
- type of constraint
- See Also:
-
equals
-
hashCode
public final int hashCode() -
toString
-
getValidateSql
Builds and returns sql query to validate current constraint.- Returns:
- sql query to validate current constraint
- See Also:
-
ofType
@Nonnull public static Constraint ofType(@Nonnull String tableName, @Nonnull String constraintName, @Nonnull ConstraintType constraintType) Constructs aConstraintobject with givenConstraintType.- Parameters:
tableName- table name; should be non-blank.constraintName- constraint name; should be non-blank.constraintType- constraint type; should be non-null.- Returns:
Constraint
-