示例#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;
 }
示例#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);
   }
 }