Class Constraint
java.lang.Object
io.github.mfvanek.pg.model.constraint.Constraint
- All Implemented Interfaces:
ConstraintNameAware,DbObject,TableNameAware
An immutable representation of constraint in a database.
- Since:
- 0.11.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanRetrieves the name of the database constraint associated with this entity.Retrieves type of constraint.getName()Retrieves database object name.Retrieves database object type.Retrieves table name.Builds and returns sql query to validate current constraint.inthashCode()static ConstraintofType(PgContext pgContext, String tableName, String constraintName, ConstraintType constraintType) Constructs aConstraintobject with givenConstraintTypeand context.static ConstraintofType(String tableName, String constraintName, ConstraintType constraintType) Constructs aConstraintobject with givenConstraintType.toString()
-
Method Details
-
getName
Retrieves database object name. -
getObjectType
Retrieves database object type.- Specified by:
getObjectTypein interfaceDbObject- Returns:
- database object type
-
getTableName
Retrieves table name.- Specified by:
getTableNamein interfaceTableNameAware- Returns:
- table name
-
getConstraintName
Retrieves the name of the database constraint associated with this entity.- Specified by:
getConstraintNamein interfaceConstraintNameAware- Returns:
- the name of the constraint as a non-null
String.
-
getConstraintType
Retrieves type of constraint.- Specified by:
getConstraintTypein interfaceConstraintNameAware- Returns:
- type of constraint
- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-
getValidateSql
Builds and returns sql query to validate current constraint.- Returns:
- sql query to validate current constraint
- See Also:
-
ofType
public static Constraint ofType(String tableName, String constraintName, 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
-
ofType
public static Constraint ofType(PgContext pgContext, String tableName, String constraintName, ConstraintType constraintType) Constructs aConstraintobject with givenConstraintTypeand context.- Parameters:
pgContext- the schema context to enrich table name; must be non-null.tableName- table name; should be non-blank.constraintName- constraint name; should be non-blank.constraintType- constraint type; should be non-null.- Returns:
Constraint- Since:
- 0.14.3
-