public int compareTo(Object obj) { if (obj == null) { return -1; } ShoppingCart shoppingCart = (ShoppingCart) obj; String pk = shoppingCart.getPrimaryKey(); return getPrimaryKey().compareTo(pk); }
public boolean equals(Object obj) { if (obj == null) { return false; } ShoppingCart shoppingCart = null; try { shoppingCart = (ShoppingCart) obj; } catch (ClassCastException cce) { return false; } String pk = shoppingCart.getPrimaryKey(); if (getPrimaryKey().equals(pk)) { return true; } else { return false; } }