public boolean contains(Article article) { for (Wish wish : wishes) { Long searchId = article.getId(); Long idInWishList = wish.getArticle().getId(); if (searchId.equals(idInWishList)) { return true; } } return false; }
public void removeFromWishList(Article article) { if (contains(article)) { Wish wishToRemove = null; for (Wish wish : wishes) { if (wish.getArticle().getId().equals(article.getId())) { wishToRemove = wish; break; } } wishes.remove(wishToRemove); } }