Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
  /**
   * {@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;
  }