class LegacyCliAdapter implements CliAdapter, Callable<CliResult> {

    ConfigBuilder applyOverrides(ConfigBuilder configBuilder, KeyDataBuilder keyDataBuilder) {

        Optional.ofNullable(overrides.workdir).ifPresent(configBuilder::workdir);
        Optional.ofNullable(overrides.workdir).ifPresent(keyDataBuilder::withWorkingDirectory);

        Optional.ofNullable(overrides.url)
                .map(
                        url -> {
                            try {
                                return new URL(url);
                            } catch (MalformedURLException e) {
                                throw new RuntimeException("Bad server url given: " + e.getMessage());
                            }
                        })
                .map(uri -> uri.getProtocol() + "://" + uri.getHost())
                .ifPresent(configBuilder::serverHostname);

        Optional.ofNullable(overrides.port).ifPresent(configBuilder::serverPort);
        Optional.ofNullable(overrides.socket).ifPresent(configBuilder::unixSocketFile);
        Optional.ofNullable(overrides.othernodes).ifPresent(configBuilder::peers);
        Optional.ofNullable(overrides.publickeys).ifPresent(keyDataBuilder::withPublicKeys);
        Optional.ofNullable(overrides.privatekeys).ifPresent(keyDataBuilder::withPrivateKeys);
        Optional.ofNullable(overrides.alwayssendto).ifPresent(configBuilder::alwaysSendTo);
        Optional.ofNullable(overrides.passwords).ifPresent(keyDataBuilder::withPrivateKeyPasswordFile);

        Optional.ofNullable(overrides.storage)
                .map(JdbcConfigFactory::fromLegacyStorageString)
                .ifPresent(configBuilder::jdbcConfig);

        if (overrides.whitelist) {
            configBuilder.useWhiteList(true);
        }

        Optional.ofNullable(overrides.tls).ifPresent(configBuilder::sslAuthenticationMode);
        Optional.ofNullable(overrides.tlsservertrust).ifPresent(configBuilder::sslServerTrustMode);
        Optional.ofNullable(overrides.tlsclienttrust).ifPresent(configBuilder::sslClientTrustMode);
        Optional.ofNullable(overrides.tlsservercert).ifPresent(configBuilder::sslServerTlsCertificatePath);
        Optional.ofNullable(overrides.tlsclientcert).ifPresent(configBuilder::sslClientTlsCertificatePath);
        Optional.ofNullable(overrides.tlsserverchain).ifPresent(configBuilder::sslServerTrustCertificates);
        Optional.ofNullable(overrides.tlsclientchain).ifPresent(configBuilder::sslClientTrustCertificates);
        Optional.ofNullable(overrides.tlsserverkey).ifPresent(configBuilder::sslServerTlsKeyPath);
        Optional.ofNullable(overrides.tlsclientkey).ifPresent(configBuilder::sslClientTlsKeyPath);
        Optional.ofNullable(overrides.tlsknownservers).ifPresent(configBuilder::sslKnownServersFile);
        Optional.ofNullable(overrides.tlsknownclients).ifPresent(configBuilder::sslKnownClientsFile);

        final KeyConfiguration keyConfiguration = keyDataBuilder.build();

        if (!keyConfiguration.getKeyData().isEmpty()) {
            configBuilder.keyData(keyConfiguration);
        } else if (overrides.passwords != null) {
            SystemAdapter.INSTANCE
                    .err()
                    .println(
                            "Info: Public/Private key data not provided in overrides. Overriden password file has not been added to config.");
        }

        return configBuilder;
    }

    public  LegacyCliAdapter();

}