public void addMessage(Message message) {
   data.add(message);
   Message last = data.get(data.size() - 1);
   if (last.getText().length() > MESSAGE_LENGTH) {
     System.out.println(RED + "WARNING: long message (more than 140 symbols)." + END);
   }
   System.out.println("Successfully added: " + last.getFormattedMessage());
   log("ADD " + last.getId() + " " + last.getAuthor() + " " + last.getText());
   saveMessagesToJsonFile(MESSAGES_EXTERNAL_STORAGE);
 }
 private void searchByRegex(String regex) throws Exception {
   System.out.println("BY REGULAR EXPRESSION: " + regex);
   int counter = 0;
   for (Message i : data) {
     if (Pattern.matches(regex, i.getText())) {
       System.out.println(i.getFormattedMessage());
       counter++;
     }
   }
   if (counter == 0) {
     System.out.println("nothing found");
     log("SEARCH by regex: " + regex + ", nothing found");
   } else {
     log("SEARCH by regex: " + regex + ", found: " + counter);
   }
 }
 private void searchByKeyword(String keyword) throws Exception {
   System.out.println("BY KEYWORD: " + keyword);
   int counter = 0;
   for (Message i : data) {
     if (i.getText().contains(keyword)) {
       System.out.println(i.getFormattedMessage());
       counter++;
     }
   }
   if (counter == 0) {
     System.out.println("nothing found");
     log("SEARCH by keyword: " + keyword + ", nothing found");
   } else {
     log("SEARCH by keyword: " + keyword + ", found: " + counter);
   }
 }