Beispiel #1
0
  @Override
  public int compareTo(Item another) {

    int comp1 = 0;
    if (getCategory() != null && another.getCategory() != null)
      comp1 = getCategory().compareToIgnoreCase(another.getCategory());
    else if (getCategory() == null) comp1 = -1;
    else if (another.getCategory() == null) comp1 = 1;
    else comp1 = 0;

    int comp2 = getName().compareToIgnoreCase(another.getName());
    int comp3 = getId().compareTo(another.getId());

    return comp1 * 10000 + comp2 * 100 + comp3;
  }