aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gmail.com>2012-10-15 10:50:32 -0400
committerJames Moger <james.moger@gmail.com>2012-10-15 10:50:32 -0400
commit913ac2ce21edba56cc4b620e194f4bddce4b3cb2 (patch)
treedc804cb35df6f2017a7f46a67a242b0ba636d31a
parentc3bb1e38da077b88192f6586033d173a6bc96eee (diff)
downloadiciql-913ac2ce21edba56cc4b620e194f4bddce4b3cb2.tar.gz
iciql-913ac2ce21edba56cc4b620e194f4bddce4b3cb2.zip
Eliminate redundant methods
-rw-r--r--src/com/iciql/TableDefinition.java51
1 files changed, 4 insertions, 47 deletions
diff --git a/src/com/iciql/TableDefinition.java b/src/com/iciql/TableDefinition.java
index c348295..a2b4f36 100644
--- a/src/com/iciql/TableDefinition.java
+++ b/src/com/iciql/TableDefinition.java
@@ -346,34 +346,10 @@ public class TableDefinition<T> {
ConstraintDeferrabilityType deferrabilityType) {
List<String> columnNames = mapColumnNames(modelFields);
List<String> referenceColumnNames = mapColumnNames(refModelFields);
- addForeignKey(name, columnNames, refTableName, referenceColumnNames,
+ addConstraintForeignKey(name, columnNames, refTableName, referenceColumnNames,
deleteType, updateType, deferrabilityType);
}
- /**
- * Defines a foreign key constraint.
- *
- * @param name
- * @param columnNames
- */
- private void addForeignKey(String name, List<String> columnNames, String referenceTableName,
- List<String> referenceColumnNames, ConstraintDeleteType deleteType,
- ConstraintUpdateType updateType, ConstraintDeferrabilityType deferrabilityType) {
- ConstraintForeignKeyDefinition constraint = new ConstraintForeignKeyDefinition();
- if (StringUtils.isNullOrEmpty(name)) {
- constraint.constraintName = tableName + "_" + constraintsUnique.size();
- } else {
- constraint.constraintName = name;
- }
- constraint.foreignColumns = Utils.newArrayList(columnNames);
- constraint.referenceTable = referenceTableName;
- constraint.referenceColumns = Utils.newArrayList(referenceColumnNames);
- constraint.deleteType = deleteType;
- constraint.updateType = updateType;
- constraint.deferrabilityType = deferrabilityType;
- constraintsForeignKey.add(constraint);
- }
-
void defineColumnName(Object column, String columnName) {
FieldDefinition def = fieldMap.get(column);
if (def != null) {
@@ -1082,12 +1058,12 @@ public class TableDefinition<T> {
private void addConstraintForeignKey(IQContraintForeignKey constraint) {
List<String> foreignColumns = Arrays.asList(constraint.foreignColumns());
List<String> referenceColumns = Arrays.asList(constraint.referenceColumns());
- addContraintForeignKey(constraint.name(), foreignColumns, constraint.referenceName(), referenceColumns, constraint.deleteType(), constraint.updateType(), constraint.deferrabilityType());
+ addConstraintForeignKey(constraint.name(), foreignColumns, constraint.referenceName(), referenceColumns, constraint.deleteType(), constraint.updateType(), constraint.deferrabilityType());
}
private void addConstraintUnique(IQContraintUnique constraint) {
List<String> uniqueColumns = Arrays.asList(constraint.uniqueColumns());
- addContraintUnique(constraint.name(), uniqueColumns);
+ addConstraintUnique(constraint.name(), uniqueColumns);
}
/**
@@ -1108,7 +1084,7 @@ public class TableDefinition<T> {
* @param deferrabilityType
* deferrability mode
*/
- private void addContraintForeignKey(String name,
+ private void addConstraintForeignKey(String name,
List<String> foreignColumns, String referenceName,
List<String> referenceColumns, ConstraintDeleteType deleteType,
ConstraintUpdateType updateType, ConstraintDeferrabilityType deferrabilityType) {
@@ -1127,25 +1103,6 @@ public class TableDefinition<T> {
constraintsForeignKey.add(constraint);
}
- /**
- * Defines a unique constraint with the specified parameters.
- *
- * @param name
- * name of the constraint
- * @param uniqueColumns
- * list of columns declared as unique
- */
- private void addContraintUnique(String name, List<String> uniqueColumns) {
- ConstraintUniqueDefinition constraint = new ConstraintUniqueDefinition();
- if (StringUtils.isNullOrEmpty(name)) {
- constraint.constraintName = tableName + "_" + constraintsUnique.size();
- } else {
- constraint.constraintName = name;
- }
- constraint.uniqueColumns = Utils.newArrayList(uniqueColumns);
- constraintsUnique.add(constraint);
- }
-
private void addIndex(IQIndex index) {
List<String> columns = Arrays.asList(index.value());
addIndex(index.name(), index.type(), columns);