From: James Moger Date: Mon, 15 Oct 2012 14:50:32 +0000 (-0400) Subject: Eliminate redundant methods X-Git-Tag: v1.2.0~21 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=913ac2ce21edba56cc4b620e194f4bddce4b3cb2;p=iciql.git Eliminate redundant methods --- 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 { ConstraintDeferrabilityType deferrabilityType) { List columnNames = mapColumnNames(modelFields); List 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 columnNames, String referenceTableName, - List 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 { private void addConstraintForeignKey(IQContraintForeignKey constraint) { List foreignColumns = Arrays.asList(constraint.foreignColumns()); List 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 uniqueColumns = Arrays.asList(constraint.uniqueColumns()); - addContraintUnique(constraint.name(), uniqueColumns); + addConstraintUnique(constraint.name(), uniqueColumns); } /** @@ -1108,7 +1084,7 @@ public class TableDefinition { * @param deferrabilityType * deferrability mode */ - private void addContraintForeignKey(String name, + private void addConstraintForeignKey(String name, List foreignColumns, String referenceName, List referenceColumns, ConstraintDeleteType deleteType, ConstraintUpdateType updateType, ConstraintDeferrabilityType deferrabilityType) { @@ -1127,25 +1103,6 @@ public class TableDefinition { 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 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 columns = Arrays.asList(index.value()); addIndex(index.name(), index.type(), columns);