Пример #1
0
 public void deleteReadMessages() {
   Iterator<Message> it = this.list.iterator();
   while (it.hasNext()) {
     Message message = (Message) it.next();
     if (message.isRead() == true) {
       this.list.remove(message);
     }
   }
 }
Пример #2
0
  public List<Message> readNewMessages() {

    List<Message> list = new ArrayList<Message>();
    List<Message> listNewMessages = new ArrayList<Message>();
    Iterator<Message> it = this.list.iterator();

    while (it.hasNext()) {
      Message message = (Message) it.next();
      if (message.isRead() == false) {
        listNewMessages.add(message);
        this.list.remove(message);
        message.setIsRead();
        this.list.add(message);
      }
      list.add(message);
    }
    this.setListMessages(list);
    return listNewMessages;
  }