public int compareTo(final ColumnMap o) { int compare = 0; if (compare == 0) { compare = primaryKeyColumn.compareTo(o.getPrimaryKeyColumn()); } if (compare == 0) { compare = foreignKeyColumn.compareTo(o.getForeignKeyColumn()); } return compare; }
/** * {@inheritDoc} * * <p>Note: Since indexes are not always explicitly named in databases, the sorting routine orders * the indexes by the names of the columns in the index. */ @Override public int compareTo(final NamedObject obj) { if (obj == null) { return -1; } final Index other = (Index) obj; int comparison = 0; final Column[] thisColumns = getColumns(); final Column[] otherColumns = other.getColumns(); if (comparison == 0) { comparison = thisColumns.length - otherColumns.length; } if (comparison == 0) { for (int i = 0; i < thisColumns.length; i++) { final Column thisColumn = thisColumns[i]; final Column otherColumn = otherColumns[i]; if (comparison == 0) { comparison = thisColumn.compareTo(otherColumn); } else { break; } } } if (comparison == 0) { comparison = super.compareTo(other); } return comparison; }