Source:
<code>public static void export(String storageDir, String formid, Path exportPath, String baseFilename, boolean includeMediaFiles, boolean overwriteFiles, Optional<LocalDate> startDate, Optional<LocalDate> endDate, Optional<Path> maybePemFile) { CliEventsCompanion.attach(log); bootCache(storageDir); Optional<BriefcaseFormDefinition> maybeFormDefinition = FileSystemUtils.getBriefcaseFormList().stream() .filter(form -> form.getFormId().equals(formid)) .findFirst(); BriefcaseFormDefinition formDefinition = maybeFormDefinition.orElseThrow(() -> new FormNotFoundException(formid)); if (formDefinition.isFileEncryptedForm() || formDefinition.isFieldEncryptedForm()) { Path pemFile = maybePemFile <START> .filter(file -> !Files.exists(file)) <END> .orElseThrow(() -> new BriefcaseException("Missing pem file configuration")); try (PEMReader rdr = new PEMReader(new BufferedReader(new InputStreamReader(Files.newInputStream(pemFile), "UTF-8")))) { Object o = Optional.ofNullable(rdr.readObject()).orElseThrow(() -> new BriefcaseException("Can't parse Pem file")); Optional<PrivateKey> privKey; if (o instanceof KeyPair) privKey = Optional.of(((KeyPair) o).getPrivate()); else if (o instanceof PrivateKey) privKey = Optional.of((PrivateKey) o); else privKey = Optional.empty(); formDefinition.setPrivateKey(privKey.orElseThrow(() -> new BriefcaseException("No private key found on Pem file"))); EventBus.publish(new ExportProgressEvent("Successfully parsed Pem file", formDefinition)); } catch (IOException e) { throw new BriefcaseException("Can't parse Pem file"); } } System.out.println("Exporting form " + formDefinition.getFormName() + " (" + formDefinition.getFormId() + ") to: " + exportPath); ExportToCsv.export(exportPath, formDefinition, baseFilename, includeMediaFiles, overwriteFiles, startDate, endDate); BriefcasePreferences.forClass(ExportPanel.class).put(buildExportDateTimePrefix(formDefinition.getFormId()), LocalDateTime.now().format(ISO_DATE_TIME)); }</code><technical_language>Ooh, nice! (The filter) .filter(Files::notExists)</technical_language>

Target:
public static void export(String storageDir, String formid, Path exportPath, String baseFilename, boolean includeMediaFiles, boolean overwriteFiles, Optional<LocalDate> startDate, Optional<LocalDate> endDate, Optional<Path> maybePemFile) { CliEventsCompanion.attach(log); bootCache(storageDir); Optional<BriefcaseFormDefinition> maybeFormDefinition = FileSystemUtils.getBriefcaseFormList().stream() .filter(form -> form.getFormId().equals(formid)) .findFirst(); BriefcaseFormDefinition formDefinition = maybeFormDefinition.orElseThrow(() -> new FormNotFoundException(formid)); if (formDefinition.isFileEncryptedForm() || formDefinition.isFieldEncryptedForm()) { Path pemFile = maybePemFile .filter(Files::exists) .orElseThrow(() -> new BriefcaseException("Missing pem file configuration")); try (PEMReader rdr = new PEMReader(new BufferedReader(new InputStreamReader(Files.newInputStream(pemFile), "UTF-8")))) { Object o = Optional.ofNullable(rdr.readObject()).orElseThrow(() -> new BriefcaseException("Can't parse Pem file")); Optional<PrivateKey> privKey; if (o instanceof KeyPair) privKey = Optional.of(((KeyPair) o).getPrivate()); else if (o instanceof PrivateKey) privKey = Optional.of((PrivateKey) o); else privKey = Optional.empty(); formDefinition.setPrivateKey(privKey.orElseThrow(() -> new BriefcaseException("No private key found on Pem file"))); EventBus.publish(new ExportProgressEvent("Successfully parsed Pem file", formDefinition)); } catch (IOException e) { throw new BriefcaseException("Can't parse Pem file"); } } System.out.println("Exporting form " + formDefinition.getFormName() + " (" + formDefinition.getFormId() + ") to: " + exportPath); ExportToCsv.export(exportPath, formDefinition, baseFilename, includeMediaFiles, overwriteFiles, startDate, endDate); BriefcasePreferences.forClass(ExportPanel.class).put(buildExportDateTimePrefix(formDefinition.getFormId()), LocalDateTime.now().format(ISO_DATE_TIME)); }