<commit_before>package es.guiguegon.geoapi.di.modules;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.concurrent.TimeUnit;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import es.guiguegon.geoapi.data.net.GeoService;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by guiguegon on 12/11/2016.
 */

@Module
public class NetworkModule {

    private final static int DEFAULT_TIMEOUT = 30;

    private boolean debug;
    private int timeout;
    private String baseUrl;

    private NetworkModule(Builder builder) {
        this.debug = builder.debug;
        this.timeout = builder.timeout;
        this.baseUrl = builder.baseUrl;
    }

    @Provides
    @Singleton
    OkHttpClient provideOkHttpClient(OkHttpClient.Builder builder) {
        return builder.build();
    }

    @Provides
    @Singleton
    OkHttpClient.Builder provideOkHttpClientBuilder(
            HttpLoggingInterceptor httpLoggingInterceptor) {
        OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
        clientBuilder.connectTimeout(timeout, TimeUnit.SECONDS);
        clientBuilder.readTimeout(timeout, TimeUnit.SECONDS);
        if (debug) {
            clientBuilder.addInterceptor(httpLoggingInterceptor);
        }
        return clientBuilder;
    }

    @Provides
    @Singleton
    HttpLoggingInterceptor provideOkHttpLogginClient() {
        return new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY);
    }

    @Provides
    @Singleton
    Gson provideGson() {
        return new GsonBuilder().create();
    }

    @Provides
    @Singleton
    Retrofit provideRetrofit(Gson gson) {
        return new Retrofit.Builder()
                .baseUrl(baseUrl)
                .addConverterFactory(GsonConverterFactory.create(gson))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
    }

    @Provides
    @Singleton
    GeoService provideGeoService(Retrofit retrofit) {
        return retrofit.create(GeoService.class);
    }

    public static class Builder {

        private boolean debug;
        private String baseUrl;
        private int timeout = DEFAULT_TIMEOUT;

        public Builder() {
        }

        public Builder setDebug(boolean debug) {
            this.debug = debug;
            return this;
        }

        public Builder setTimeout(int timeout) {
            this.timeout = timeout;
            return this;
        }

        public Builder setBaseUrl(String baseUrl) {
            this.baseUrl = baseUrl;
            return this;
        }

        public NetworkModule build() {
            return new NetworkModule(this);
        }
    }
}
<commit_msg>Added OkHttpClient<commit_after>package es.guiguegon.geoapi.di.modules;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import dagger.Module;
import dagger.Provides;
import es.guiguegon.geoapi.data.net.GeoService;
import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by guiguegon on 12/11/2016.
 */

@Module
public class NetworkModule {

    private final static int DEFAULT_TIMEOUT = 30;

    private boolean debug;
    private int timeout;
    private String baseUrl;

    private NetworkModule(Builder builder) {
        this.debug = builder.debug;
        this.timeout = builder.timeout;
        this.baseUrl = builder.baseUrl;
    }

    @Provides
    @Singleton
    OkHttpClient provideOkHttpClient(OkHttpClient.Builder builder) {
        return builder.build();
    }

    @Provides
    @Singleton
    OkHttpClient.Builder provideOkHttpClientBuilder(HttpLoggingInterceptor httpLoggingInterceptor) {
        OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
        clientBuilder.connectTimeout(timeout, TimeUnit.SECONDS);
        clientBuilder.readTimeout(timeout, TimeUnit.SECONDS);
        if (debug) {
            clientBuilder.addInterceptor(httpLoggingInterceptor);
        }
        return clientBuilder;
    }

    @Provides
    @Singleton
    HttpLoggingInterceptor provideOkHttpLogginClient() {
        return new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY);
    }

    @Provides
    @Singleton
    Gson provideGson() {
        return new GsonBuilder().create();
    }

    @Provides
    @Singleton
    Retrofit provideRetrofit(Gson gson, OkHttpClient okHttpClient) {
        return new Retrofit.Builder().baseUrl(baseUrl).client(okHttpClient)
                .addConverterFactory(GsonConverterFactory.create(gson))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
    }

    @Provides
    @Singleton
    GeoService provideGeoService(Retrofit retrofit) {
        return retrofit.create(GeoService.class);
    }

    public static class Builder {

        private boolean debug;
        private String baseUrl;
        private int timeout = DEFAULT_TIMEOUT;

        public Builder() {
        }

        public Builder setDebug(boolean debug) {
            this.debug = debug;
            return this;
        }

        public Builder setTimeout(int timeout) {
            this.timeout = timeout;
            return this;
        }

        public Builder setBaseUrl(String baseUrl) {
            this.baseUrl = baseUrl;
            return this;
        }

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

{'fraction_non_alphanumeric': 0.08010955152345087, 'fraction_numerical': 0.005135227661759671, 'mean_word_length': 2.6473158551810236, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4670296', 'n_tokens_mistral': 1668, 'n_tokens_neox': 1612, 'n_words': 329}