public static Note mergeNotes(List<Note> notes, boolean keepMergedNotes) {
    boolean locked = false;
    ArrayList<Attachment> attachments = new ArrayList<>();
    String reminder = null;
    String reminderRecurrenceRule = null;
    Double latitude = null;
    Double longitude = null;

    Note mergedNote = new Note();
    mergedNote.setTitle(notes.get(0).getTitle());
    mergedNote.setArchived(notes.get(0).isArchived());
    mergedNote.setCategory(notes.get(0).getCategory());
    StringBuilder content = new StringBuilder();
    // Just first note title must not be included into the content
    boolean includeTitle = false;

    for (Note note : notes) {
      appendContent(note, content, includeTitle);
      locked = locked || note.isLocked();
      String currentReminder = note.getAlarm();
      if (!StringUtils.isEmpty(currentReminder) && reminder == null) {
        reminder = currentReminder;
        reminderRecurrenceRule = note.getRecurrenceRule();
      }
      latitude = ObjectUtils.defaultIfNull(latitude, note.getLatitude());
      longitude = ObjectUtils.defaultIfNull(longitude, note.getLongitude());
      addAttachments(keepMergedNotes, note, attachments);
      includeTitle = true;
    }

    mergedNote.setContent(content.toString());
    mergedNote.setLocked(locked);
    mergedNote.setAlarm(reminder);
    mergedNote.setRecurrenceRule(reminderRecurrenceRule);
    mergedNote.setLatitude(latitude);
    mergedNote.setLongitude(longitude);
    mergedNote.setAttachmentsList(attachments);

    return mergedNote;
  }
@Test
  public void mergeNotes() {
    int notesNumber = 3;
    var notes = new ArrayList<Note>();
    for (int i = 0; i < notesNumber; i++) {
      Note note = new Note();
      note.setTitle("Merged note " + i + " title");
      note.setContent("Merged note " + i + " content");
      notes.add(note);
    }
    var mergeNote = NotesHelper.mergeNotes(notes, false);

    assertNotNull(mergeNote);
    assertEquals("Merged note 0 title", mergeNote.getTitle());
    assertTrue(mergeNote.getContent().contains("Merged note 0 content"));
    assertTrue(mergeNote.getContent().contains("Merged note 1 content"));
    assertTrue(mergeNote.getContent().contains("Merged note 2 content"));
    assertEquals(StringUtils.countMatches(mergeNote.getContent(), MERGED_NOTES_SEPARATOR), 2);
  }