/* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object o) { if (o == null) { return false; } if (!o.getClass().equals(this.getClass())) return false; Item otherItem = (Item) o; if (!otherItem.getId().equals(getId())) return false; return true; }
@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; }