Example #1
0
  /**
   * @param object
   * @return
   */
  public int compareTo(TableIndex other) {
    if (isPrimaryKey() && !other.isPrimaryKey()) return -1;
    if (!isPrimaryKey() && other.isPrimaryKey()) return 1;

    Object thisId = getId();
    Object otherId = other.getId();
    if (thisId == null || otherId == null) return getName().compareToIgnoreCase(other.getName());
    if (thisId instanceof Number)
      return ((Number) thisId).intValue() - ((Number) otherId).intValue();
    return thisId.toString().compareToIgnoreCase(otherId.toString());
  }