package io.sidecar.client;

import static com.google.common.base.Throwables.propagate;

import java.net.MalformedURLException;
import java.net.URL;

public final class ClientConfig {

    final private URL restApiBasePath;

    public ClientConfig() {
        this(new Builder());
    }

    private ClientConfig(Builder bd) {
        restApiBasePath = getOrDefault(bd.restApiBasePath, "http://localhost:8080/rest-api");
    }

    private URL getOrDefault(URL builderUrl, String defaultUrl) {
        try {
            return (builderUrl != null) ? builderUrl : new URL(defaultUrl);
        } catch (MalformedURLException e) {
            throw propagate(e);
        }
    }

    public URL getRestApiBasePath() {
        return restApiBasePath;
    }

    public static final class Builder {

        private URL restApiBasePath;

        public ClientConfig build() {
            return new ClientConfig(this);
        }

        public Builder withRestApiBasePath(URL basePath) {
            this.restApiBasePath = basePath;
            return this;
        }
    }
}

@@ -62,69 +62,95 @@
 ase.
-Throwables.propagate;%0A%0Aimport java.net.MalformedURLException;
+Preconditions.checkNotNull;%0Aimport static com.google.common.base.Throwables.propagate;%0A
 %0Aimp
@@ -288,129 +288,22 @@
 his(
-new Builder());%0A    %7D%0A%0A    private ClientConfig(Builder bd) %7B%0A        restApiBasePath = getOrDefault(bd.restApiBasePath, 
+urlFromString(
 %22htt
@@ -331,16 +331,17 @@
 st-api%22)
+)
 ;%0A    %7D%0A
@@ -350,244 +350,95 @@
    p
-rivate URL getOrDefault(URL builderUrl, String defaultUrl) %7B%0A        try %7B%0A            return (builderUrl != null) ? builderUrl : new URL(defaultUrl);%0A        %7D catch (MalformedURLException e) %7B%0A            throw propagate(e);%0A        %7D
+ublic ClientConfig(URL baseUrl) %7B%0A        this.restApiBasePath = checkNotNull(baseUrl);
 %0A   
@@ -527,21 +527,22 @@
    p
-ublic
+rivate
  static 
 fina
@@ -541,288 +541,145 @@
 tic 
-final class Builder %7B%0A%0A        private URL restApiBasePath;%0A%0A        public ClientConfig build() %7B%0A            return new ClientConfig(this);%0A        %7D%0A%0A        public Builder withRestApiBasePath(URL basePath) %7B%0A            this.restApiBasePath = basePath;%0A            return this
+URL urlFromString(String s) %7B%0A        try %7B%0A            return new URL(s);%0A        %7D catch (Exception e) %7B%0A            throw propagate(e)
 ;%0A  

remove unnecessary builder from ClientConfig