Пример #1
0
 public Message updateMessage(Message message) {
   if (message.getId() <= 0) {
     return null;
   }
   messages.put(message.getId(), message);
   return message;
 }
Пример #2
0
 public List<Message> getAllMessagesForYear(int year) {
   List<Message> messagesForYear = new ArrayList<>();
   Calendar cal = Calendar.getInstance();
   for (Message message : messages.values()) {
     cal.setTime(message.getCreated());
     if (cal.get(Calendar.YEAR) == year) {
       messagesForYear.add(message);
     }
   }
   return messagesForYear;
 }
Пример #3
0
 public Message addMessage(Message message) {
   message.setId(messages.size() + 1);
   messages.put(message.getId(), message);
   return message;
 }