Package org.jumpmind.db.model
Class ForeignKey
java.lang.Object
org.jumpmind.db.model.ForeignKey
- All Implemented Interfaces:
Serializable,Cloneable
Represents a database foreign key.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new foreign key object that has no name.ForeignKey(String name) Creates a new foreign key object.ForeignKey(String name, String foreignKeyTableName) Creates a new foreign key object. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReference(Reference reference) Adds a reference, ie.clone()booleanbooleanequalsIgnoreCase(ForeignKey otherFk) Compares this foreign key to the given one while ignoring the case of identifiers.Returns the first reference if it exists.static ForeignKey.ForeignKeyActiongetForeignKeyAction(short importedKeyAction) static ForeignKey.ForeignKeyActiongetForeignKeyActionByForeignKeyActionName(String foreignKeyActionName) Returns the foreign table.Returns the name of the foreign table.getName()Returns the name of this foreign key.getReference(int idx) Returns the indicated reference.intReturns the number of references.Returns the references.booleanhasForeignColumn(Column column) Determines whether this foreign key uses the given column as a foreign column in a reference.inthashCode()booleanhasLocalColumn(Column column) Determines whether this foreign key uses the given column as a local column in a reference.booleanDetermines whether this foreign key has an auto-generated associated index.voidremoveReference(int idx) Removes the indicated reference.voidremoveReference(Reference reference) Removes the given reference.voidsetAutoIndexPresent(boolean autoIndexPresent) Specifies whether this foreign key has an auto-generated associated index.voidsetForeignTable(Table foreignTable) Sets the foreign table.voidsetForeignTableCatalog(String foreignTableCatalog) voidsetForeignTableName(String foreignTableName) Sets the name of the foreign table.voidsetForeignTableSchema(String foreignTableSchema) voidSets the name of this foreign key.voidsetOnDeleteAction(ForeignKey.ForeignKeyAction onDeleteAction) voidsetOnUpdateAction(ForeignKey.ForeignKeyAction onUpdateAction) toString()Returns a verbose string representation of this foreign key.
-
Constructor Details
-
ForeignKey
public ForeignKey()Creates a new foreign key object that has no name. -
ForeignKey
Creates a new foreign key object.- Parameters:
name- The name of the foreign key
-
ForeignKey
Creates a new foreign key object.- Parameters:
name- The name of the foreign keyforeignKeyTableName- The name of the foreign key table
-
-
Method Details
-
getName
Returns the name of this foreign key.- Returns:
- The name
-
setName
Sets the name of this foreign key.- Parameters:
name- The name
-
getForeignTable
Returns the foreign table.- Returns:
- The foreign table
-
setForeignTable
Sets the foreign table.- Parameters:
foreignTable- The foreign table
-
getForeignTableName
Returns the name of the foreign table.- Returns:
- The table name
-
setForeignTableName
Sets the name of the foreign table. Please note that you should not use this method when manually constructing or manipulating the database model. Rather utilize thesetForeignTable(Table)method.- Parameters:
foreignTableName- The table name
-
getReferenceCount
public int getReferenceCount()Returns the number of references.- Returns:
- The number of references
-
getReference
Returns the indicated reference.- Parameters:
idx- The index- Returns:
- The reference
-
getReferences
Returns the references.- Returns:
- The references
-
getFirstReference
Returns the first reference if it exists.- Returns:
- The first reference
-
addReference
Adds a reference, ie. a mapping between a local column (in the table that owns this foreign key) and a remote column.- Parameters:
reference- The reference to add
-
removeReference
Removes the given reference.- Parameters:
reference- The reference to remove
-
removeReference
public void removeReference(int idx) Removes the indicated reference.- Parameters:
idx- The index of the reference to remove
-
hasLocalColumn
Determines whether this foreign key uses the given column as a local column in a reference.- Parameters:
column- The column to check- Returns:
trueif a reference uses the column as a local column
-
hasForeignColumn
Determines whether this foreign key uses the given column as a foreign column in a reference.- Parameters:
column- The column to check- Returns:
trueif a reference uses the column as a foreign column
-
isAutoIndexPresent
public boolean isAutoIndexPresent()Determines whether this foreign key has an auto-generated associated index.- Returns:
trueif an auto-generated index exists
-
setAutoIndexPresent
public void setAutoIndexPresent(boolean autoIndexPresent) Specifies whether this foreign key has an auto-generated associated index.- Parameters:
autoIndexPresent-trueif an auto-generated index exists
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
equals
-
equalsIgnoreCase
Compares this foreign key to the given one while ignoring the case of identifiers.- Parameters:
otherFk- The other foreign key- Returns:
trueif this foreign key is equal (ignoring case) to the given one
-
hashCode
public int hashCode() -
toString
-
toVerboseString
Returns a verbose string representation of this foreign key.- Returns:
- The string representation
-
getForeignTableCatalog
-
setForeignTableCatalog
-
getForeignTableSchema
-
setForeignTableSchema
-
getOnDeleteAction
-
setOnDeleteAction
-
getOnUpdateAction
-
setOnUpdateAction
-
getForeignKeyAction
-
getForeignKeyActionByForeignKeyActionName
public static ForeignKey.ForeignKeyAction getForeignKeyActionByForeignKeyActionName(String foreignKeyActionName) throws IllegalArgumentException - Throws:
IllegalArgumentException
-