@NotNull Attachment fromDto(@NotNull Mica.AttachmentDtoOrBuilder dto) { Attachment attachment = new Attachment(); attachment.setId(dto.getId()); attachment.setName(dto.getFileName()); if (dto.hasType()) attachment.setType(dto.getType()); if (dto.getDescriptionCount() > 0) attachment.setDescription(localizedStringDtos.fromDto(dto.getDescriptionList())); if (dto.hasLang()) attachment.setLang(new Locale(dto.getLang())); attachment.setSize(dto.getSize()); if (dto.hasMd5()) attachment.setMd5(dto.getMd5()); attachment.setJustUploaded(dto.getJustUploaded()); if (dto.hasTimestamps()) TimestampsDtos.fromDto(dto.getTimestamps(), attachment); if (dto.getAttributesCount() > 0) { dto.getAttributesList() .forEach(attributeDto -> attachment.addAttribute(attributeDtos.fromDto(attributeDto))); } if (dto.hasPath()) attachment.setPath(dto.getPath()); return attachment; }