class SW360AttachmentUtils {

    public static <T extends SW360HalResource<?, ?>> CompletableFuture<Optional<Path>>
    downloadAttachment(SW360AttachmentAwareClient<? extends T> client, T entity, SW360SparseAttachment attachment,
                       Path downloadPath) {
        return Optional.ofNullable(entity.getSelfLink())
                .map(self -> {
                    AttachmentDownloadProcessor downloadProcessor =
                            defaultAttachmentDownloadProcessor(attachment, downloadPath);
                    return optionalFuture(client.processAttachment(self.getHref(), attachment.getId(),
                            downloadProcessor));
                })
                .orElseGet(() -> CompletableFuture.completedFuture(Optional.empty()));
    }

    private  SW360AttachmentUtils();

}