Coverage Report - liquibase.statement.core.AddForeignKeyConstraintStatement
 
Classes in this File Line Coverage Branch Coverage Complexity
AddForeignKeyConstraintStatement
96%
32/33
100%
2/2
1.056
 
 1  
 package liquibase.statement.core;
 2  
 
 3  
 import liquibase.statement.AbstractSqlStatement;
 4  
 
 5  
 public class AddForeignKeyConstraintStatement extends AbstractSqlStatement {
 6  
 
 7  
     private String baseTableSchemaName;
 8  
     private String baseTableName;
 9  
     private String baseColumnNames;
 10  
 
 11  
     private String referencedTableSchemaName;
 12  
     private String referencedTableName;
 13  
     private String referencedColumnNames;
 14  
 
 15  
     private String constraintName;
 16  
 
 17  
     private boolean deferrable;
 18  
     private boolean initiallyDeferred;
 19  
 
 20  
     private String onDelete;
 21  
     private String onUpdate;
 22  
 
 23  
     // Some databases supports creation of FK with referention to column marked as unique, not primary
 24  
     // If FK referenced to such unique column this option should be set to false
 25  106
     private boolean referencesUniqueColumn = false;
 26  
 
 27  
     public AddForeignKeyConstraintStatement(String constraintName, String baseTableSchemaName, String baseTableName,
 28  
             String baseColumnNames, String referencedTableSchemaName, String referencedTableName,
 29  106
             String referencedColumnNames) {
 30  106
         this.baseTableSchemaName = baseTableSchemaName;
 31  106
         this.baseTableName = baseTableName;
 32  106
         this.baseColumnNames = baseColumnNames;
 33  106
         this.referencedTableSchemaName = referencedTableSchemaName;
 34  106
         this.referencedTableName = referencedTableName;
 35  106
         this.referencedColumnNames = referencedColumnNames;
 36  106
         this.constraintName = constraintName;
 37  106
     }
 38  
 
 39  
     public String getBaseTableSchemaName() {
 40  1
         return baseTableSchemaName;
 41  
     }
 42  
 
 43  
     public String getBaseTableName() {
 44  30
         return baseTableName;
 45  
     }
 46  
 
 47  
     public String getBaseColumnNames() {
 48  30
         return baseColumnNames;
 49  
     }
 50  
 
 51  
     public String getReferencedTableSchemaName() {
 52  1
         return referencedTableSchemaName;
 53  
     }
 54  
 
 55  
     public String getReferencedTableName() {
 56  30
         return referencedTableName;
 57  
     }
 58  
 
 59  
     public String getReferencedColumnNames() {
 60  30
         return referencedColumnNames;
 61  
     }
 62  
 
 63  
     public String getConstraintName() {
 64  1
         return constraintName;
 65  
     }
 66  
 
 67  
     public boolean isDeferrable() {
 68  30
         return deferrable;
 69  
     }
 70  
 
 71  
     public String getOnDelete() {
 72  1
         return onDelete;
 73  
     }
 74  
 
 75  
     public String getOnUpdate() {
 76  0
         return onUpdate;
 77  
     }
 78  
 
 79  
     public AddForeignKeyConstraintStatement setDeferrable(boolean deferrable) {
 80  105
         this.deferrable = deferrable;
 81  105
         return this;
 82  
     }
 83  
 
 84  
     public boolean isInitiallyDeferred() {
 85  30
         return initiallyDeferred;
 86  
     }
 87  
 
 88  
     public AddForeignKeyConstraintStatement setInitiallyDeferred(boolean initiallyDeferred) {
 89  105
         this.initiallyDeferred = initiallyDeferred;
 90  105
         return this;
 91  
     }
 92  
 
 93  
     public AddForeignKeyConstraintStatement setOnUpdate(String updateRule) {
 94  105
         this.onUpdate = updateRule;
 95  105
         return this;
 96  
     }
 97  
 
 98  
     public AddForeignKeyConstraintStatement setOnDelete(String deleteRule) {
 99  105
         this.onDelete = deleteRule;
 100  105
         return this;
 101  
     }
 102  
 
 103  
     public boolean getReferencesUniqueColumn() {
 104  118
         return referencesUniqueColumn;
 105  
     }
 106  
 
 107  
     public AddForeignKeyConstraintStatement setReferencesUniqueColumn(Boolean referencesUniqueColumn) {
 108  105
         if (referencesUniqueColumn != null) {
 109  1
             this.referencesUniqueColumn = referencesUniqueColumn;
 110  
         }
 111  105
         return this;
 112  
     }
 113  
 }