/**
  * assigns a document id to all attachments in the passed in collection based on the passed in
  * type to doc number map.
  *
  * @param <T> the type of attachments
  * @param attachments the collection of attachments that require doc number assignment
  * @param typeToDocNumber the map that contains all the highest doc numbers of existing
  *     attachments based on type code
  */
 private void assignDocumentId(
     List<SubAwardAttachments> attachments, final Map<String, Integer> typeToDocNumber) {
   for (SubAwardAttachments attachment : attachments) {
     if (attachment.isNew()) {
       final Integer nextDocNumber =
           SubAwardAttachmentFormBean.createNextDocNumber(
               typeToDocNumber.get(attachment.getSubAwardAttachmentTypeCode()));
       attachment.setDocumentId(nextDocNumber);
     }
   }
 }
  private void syncNewFiles(List<SubAwardAttachments> attachments) {
    assert attachments != null : "the attachments was null";

    for (SubAwardAttachments attachment : attachments) {
      if (SubAwardAttachmentFormBean.doesNewFileExist(attachment)) {
        final AttachmentFile newFile = AttachmentFile.createFromFormFile(attachment.getNewFile());
        // setting the sequence number to the old file sequence number
        if (attachment.getFile() != null) {
          newFile.setSequenceNumber(attachment.getFile().getSequenceNumber());
        }
        attachment.setFile(newFile);
      }
    }
  }