public ArrayList<Message> getAllMessages(String authorName) { ArrayList<Message> finalList = new ArrayList<Message>(); ArrayList<Message> al = new ArrayList<Message>(messages.values()); for (Message m : al) { if (m.getAuthor().equals(authorName)) finalList.add(m); } return finalList; }
public Message editMessage(Message message) { messages.put(message.getId(), message); return message; }
public Message addMessage(Message message) { message.setId(messages.size() + 1); // Message m = new Message(messages.size()+1, message.getMessage()); messages.put(messages.size() + 1, message); return message; }