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); } } }
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; }