コード例 #1
0
  public int compareTo(Object obj) {
    if (obj == null) {
      return -1;
    }

    ShoppingCart shoppingCart = (ShoppingCart) obj;
    String pk = shoppingCart.getPrimaryKey();

    return getPrimaryKey().compareTo(pk);
  }
コード例 #2
0
  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;
    }
  }