/** * @param seenOffer * @param delta acceptable difference in percent * @return */ public boolean sameAs(Offer seenOffer, double delta) { if (!(availabeItems.size() == seenOffer.availabeItems.size())) return false; for (OfferItem item : availabeItems) { OfferItem sameItem = seenOffer.findItem(item.getProductData().getProductId()); if (sameItem == null) return false; if (!sameItem.sameAs(item, delta)) return false; } return true; }
private OfferItem findItem(Id productId) { for (OfferItem item : availabeItems) { if (item.getProductData().getProductId().equals(productId)) return item; } return null; }