Source:
public String constraintDataToSQL(ConstraintElement constraint, String tableID) { StringBuilder toReturn = new StringBuilder(); String id = formatQuotedString(constraint.getId(), "\\."); String type = constraint.getConstraintType().toString(); String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ","); if (Strings.isValid(id) && Strings.isValid(appliesTo)) { toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")"); if (constraint instanceof ForeignKey) { ForeignKey fk = (ForeignKey) constraint; List<ReferenceClause> refs = fk.getReferences(); for (ReferenceClause ref : refs) { String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\."); String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ","); String onUpdate = ""; if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) { onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString(); } String onDelete = ""; if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) { onDelete = "ON DELETE " + ref.getOnDeleteAction().toString(); } if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) { toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")"); if (!onUpdate.equals("")) { toReturn.append(" " + onUpdate); } if (!onDelete.equals("")) { toReturn.append(" " + onDelete); } } else { getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t %s", tableID, fk); } } } } else { getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t %s", tableID, constraint); } return toReturn.toString(); }

Target:
public String constraintDataToSQL(ConstraintElement constraint, String tableID) { StringBuilder toReturn = new StringBuilder(); String id = formatQuotedString(constraint.getId(), "\\."); String type = constraint.getConstraintType().toString(); String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ","); if (Strings.isValid(id) && Strings.isValid(appliesTo)) { toReturn.append("CONSTRAINT ").append(id).append(" ").append(type).append(" (").append(appliesTo).append(")"); if (constraint instanceof ForeignKey) { ForeignKey fk = (ForeignKey) constraint; List<ReferenceClause> refs = fk.getReferences(); for (ReferenceClause ref : refs) { String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\."); String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ","); String onUpdate = ""; if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) { onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString(); } String onDelete = ""; if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) { onDelete = "ON DELETE " + ref.getOnDeleteAction().toString(); } if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) { toReturn.append(" REFERENCES ").append(refTable).append(" (").append(refColumns).append(")"); if (!onUpdate.equals("")) { toReturn.append(" ").append(onUpdate); } if (!onDelete.equals("")) { toReturn.append(" ").append(onDelete); } } else { getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t %s", tableID, fk); } } } } else { getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t %s", tableID, constraint); } return toReturn.toString(); }