Example #1
0
 public boolean contains(Article article) {
   for (CollectionObject collectionObject : collection) {
     Long searchId = article.getId();
     Long idInCollection = collectionObject.getArticle().getId();
     if (searchId.equals(idInCollection)) {
       return true;
     }
   }
   return false;
 }
Example #2
0
 public void removeFromCollection(Article article) {
   if (contains(article)) {
     CollectionObject collectionObjectToRemove = null;
     for (CollectionObject collectionObject : collection) {
       if (collectionObject.getArticle().getId().equals(article.getId())) {
         collectionObjectToRemove = collectionObject;
         break;
       }
     }
     collection.remove(collectionObjectToRemove);
   }
 }