Package org.pgcodekeeper.core.schema.ms
Class MsConstraintPk
java.lang.Object
org.pgcodekeeper.core.schema.PgStatement
org.pgcodekeeper.core.schema.AbstractConstraint
org.pgcodekeeper.core.schema.ms.MsConstraint
org.pgcodekeeper.core.schema.ms.MsConstraintPk
- All Implemented Interfaces:
IHashable,IConstraint,IConstraintPk,IOptionContainer,ISearchPath,ISimpleColumnContainer,IStatement
public final class MsConstraintPk
extends MsConstraint
implements IConstraintPk, IOptionContainer, ISimpleColumnContainer
Represents a Microsoft SQL PRIMARY KEY or UNIQUE constraint.
Supports both clustered and non-clustered indexes with various options.
-
Field Summary
Fields inherited from class org.pgcodekeeper.core.schema.PgStatement
GOFields inherited from interface org.pgcodekeeper.core.schema.IOptionContainer
GP_OPTION_LIST -
Constructor Summary
ConstructorsConstructorDescriptionMsConstraintPk(String name, boolean isPrimaryKey) Creates a new Microsoft SQL PRIMARY KEY or UNIQUE constraint. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddColumn(SimpleColumn column) Adds a column reference to this container.voidaddInclude(String column) Throws an exception as include columns are not supported for primary key/unique constraints.voidAdds an option to this container.booleancompare(PgStatement obj) This method does not account for nested child PgStatements.voidcompareOptions(IOptionContainer newContainer, SQLScript script) Compares options between this container and a new container, generating SQL to update differences.voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.booleancontainsColumn(String name) Checks if this constraint involves the specified column.Gets the columns involved in this constraint.Gets the SQL definition of this constraint.Gets all options for this container.booleanChecks if this primary key constraint is clustered.booleanChecks if this constraint is a primary key constraint.voidsetClustered(boolean isClustered) voidsetDataSpace(String dataSpace) Methods inherited from class org.pgcodekeeper.core.schema.ms.MsConstraint
appendAlterSQL, getCreationSQL, getDbType, getDropSQL, setDisabled, shallowCopyMethods inherited from class org.pgcodekeeper.core.schema.AbstractConstraint
getContainingSchema, getLocation, getStatementType, getTableName, isNotValid, isSubElement, setNotValidMethods inherited from class org.pgcodekeeper.core.schema.PgStatement
addAllDeps, addDep, addPrivilege, appendAlterComments, appendComments, appendOwnerSQL, canDrop, canDropBeforeCreate, checkComments, clearPrivileges, compareChildren, deepCopy, equals, getAuthor, getBareName, getChildren, getComment, getDeps, getDescendants, getDropSQL, getLibName, getName, getObjectState, getObjectState, getOwner, getParent, getPrivileges, getQualifiedName, getSQL, getTwin, getTypeName, hasChildren, hashCode, isLib, isOwned, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, toStringMethods inherited from interface org.pgcodekeeper.core.schema.IConstraint
getTableNameMethods inherited from interface org.pgcodekeeper.core.schema.ISearchPath
getContainingSchema, getDatabase, getSchemaNameMethods inherited from interface org.pgcodekeeper.core.schema.IStatement
getBareName, getComment, getName, getParent, getQualifiedName, getStatementType
-
Constructor Details
-
MsConstraintPk
Creates a new Microsoft SQL PRIMARY KEY or UNIQUE constraint.- Parameters:
name- the constraint nameisPrimaryKey- true for PRIMARY KEY, false for UNIQUE
-
-
Method Details
-
isPrimaryKey
public boolean isPrimaryKey()Description copied from interface:IConstraintChecks if this constraint is a primary key constraint.- Specified by:
isPrimaryKeyin interfaceIConstraint- Returns:
- true if this is a primary key constraint
-
isClustered
public boolean isClustered()Description copied from interface:IConstraintPkChecks if this primary key constraint is clustered.- Specified by:
isClusteredin interfaceIConstraintPk- Returns:
- true if the primary key is clustered
-
setClustered
public void setClustered(boolean isClustered) -
setDataSpace
-
getColumns
Description copied from interface:IConstraintGets the columns involved in this constraint.- Specified by:
getColumnsin interfaceIConstraint- Overrides:
getColumnsin classAbstractConstraint- Returns:
- a collection of column names
-
containsColumn
Description copied from interface:IConstraintChecks if this constraint involves the specified column.- Specified by:
containsColumnin interfaceIConstraint- Overrides:
containsColumnin classAbstractConstraint- Parameters:
name- the column name to check- Returns:
- true if the column is part of this constraint
-
addColumn
Description copied from interface:ISimpleColumnContainerAdds a column reference to this container.- Specified by:
addColumnin interfaceISimpleColumnContainer- Parameters:
column- the simple column to add
-
addInclude
Throws an exception as include columns are not supported for primary key/unique constraints.- Specified by:
addIncludein interfaceISimpleColumnContainer- Parameters:
column- the column name (not used)- Throws:
IllegalStateException- always, as this operation is unsupported
-
getOptions
Description copied from interface:IOptionContainerGets all options for this container.- Specified by:
getOptionsin interfaceIOptionContainer- Returns:
- a map of option keys to values
-
addOption
Description copied from interface:IOptionContainerAdds an option to this container.- Specified by:
addOptionin interfaceIOptionContainer- Parameters:
key- the option keyvalue- the option value
-
getDefinition
Description copied from interface:IConstraintGets the SQL definition of this constraint.- Specified by:
getDefinitionin interfaceIConstraint- Returns:
- the constraint definition
-
compare
Description copied from class:PgStatementThis method does not account for nested child PgStatements. Shallow version ofPgStatement.equals(Object)- Overrides:
comparein classMsConstraint
-
computeHash
Description copied from interface:IHashableComputes the hash of the implementing object using the provided hasher. The implementation should call appropriateputmethods on the hasher for all fields that should contribute to the hash value.- Specified by:
computeHashin interfaceIHashable- Overrides:
computeHashin classMsConstraint- Parameters:
hasher- the hasher instance to use for hash computation
-
compareOptions
Description copied from interface:IOptionContainerCompares options between this container and a new container, generating SQL to update differences.- Specified by:
compareOptionsin interfaceIOptionContainer- Parameters:
newContainer- the new container to compare againstscript- the script to append changes to
-