<commit_before>package com.charlesmadere.hummingbird.misc;

import com.charlesmadere.hummingbird.networking.HummingbirdApi;
import com.charlesmadere.hummingbird.networking.WebsiteApi;
import com.google.gson.annotations.SerializedName;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public final class RetrofitUtils {

    private static final String TAG = "RetrofitUtils";

    private static HummingbirdApi sHummingbirdApi;
    private static Retrofit sHummingbirdRetrofit;
    private static Retrofit sWebsiteRetrofit;
    private static WebsiteApi sWebsiteApi;


    public static synchronized HummingbirdApi getHummingbirdApi() {
        if (sHummingbirdApi == null) {
            Timber.d(TAG, "creating Hummingbird Api instance");
            final Retrofit retrofit = getHummingbirdRetrofit();
            sHummingbirdApi = retrofit.create(HummingbirdApi.class);
        }

        return sHummingbirdApi;
    }

    public static synchronized Retrofit getHummingbirdRetrofit() {
        if (sHummingbirdRetrofit == null) {
            Timber.d(TAG, "creating Hummingbird Retrofit instance");
            sHummingbirdRetrofit = new Retrofit.Builder()
                    .client(OkHttpUtils.getOkHttpClient())
                    .addConverterFactory(GsonConverterFactory.create(GsonUtils.getGson()))
                    .addConverterFactory(new EnumConverterFactory())
                    .baseUrl(Constants.HUMMINGBIRD_URL)
                    .build();
        }

        return sHummingbirdRetrofit;
    }

    private static <E extends Enum<E>> String getSerializedName(final E e) {
        try {
            return e.getClass().getField(e.name()).getAnnotation(SerializedName.class).value();
        } catch (final NoSuchFieldException e1) {
            return e.name();
        }
    }

    public static synchronized WebsiteApi getWebsiteApi() {
        if (sWebsiteApi == null) {
            Timber.d(TAG, "creating Website Api instance");
            final Retrofit retrofit = getWebsiteRetrofit();
            sWebsiteApi = retrofit.create(WebsiteApi.class);
        }

        return sWebsiteApi;
    }

    public static synchronized Retrofit getWebsiteRetrofit() {
        if (sWebsiteRetrofit == null) {
            Timber.d(TAG, "creating Website Retrofit instance");
            sWebsiteRetrofit = new Retrofit.Builder()
                    .client(OkHttpUtils.getOkHttpClient())
                    .addConverterFactory(GsonConverterFactory.create(GsonUtils.getGson()))
                    .addConverterFactory(new EnumConverterFactory())
                    .baseUrl(Constants.WEBSITE_URL)
                    .build();
        }

        return sWebsiteRetrofit;
    }<commit_msg>only use one EnumConverterFactory and GsonConverterFactory<commit_after>package com.charlesmadere.hummingbird.misc;

import com.charlesmadere.hummingbird.networking.HummingbirdApi;
import com.charlesmadere.hummingbird.networking.WebsiteApi;
import com.google.gson.annotations.SerializedName;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public final class RetrofitUtils {

    private static final String TAG = "RetrofitUtils";

    private static EnumConverterFactory sEnumConverterFactory;
    private static GsonConverterFactory sGsonConverterFactory;
    private static HummingbirdApi sHummingbirdApi;
    private static Retrofit sHummingbirdRetrofit;
    private static Retrofit sWebsiteRetrofit;
    private static WebsiteApi sWebsiteApi;


    private static synchronized EnumConverterFactory getEnumConverterFactory() {
        if (sEnumConverterFactory == null) {
            sEnumConverterFactory = new EnumConverterFactory();
        }

        return sEnumConverterFactory;
    }

    public static synchronized GsonConverterFactory getGsonConverterFactory() {
        if (sGsonConverterFactory == null) {
            sGsonConverterFactory = GsonConverterFactory.create(GsonUtils.getGson());
        }

        return sGsonConverterFactory;
    }

    public static synchronized HummingbirdApi getHummingbirdApi() {
        if (sHummingbirdApi == null) {
            Timber.d(TAG, "creating Hummingbird Api instance");
            final Retrofit retrofit = getHummingbirdRetrofit();
            sHummingbirdApi = retrofit.create(HummingbirdApi.class);
        }

        return sHummingbirdApi;
    }

    public static synchronized Retrofit getHummingbirdRetrofit() {
        if (sHummingbirdRetrofit == null) {
            Timber.d(TAG, "creating Hummingbird Retrofit instance");
            sHummingbirdRetrofit = new Retrofit.Builder()
                    .client(OkHttpUtils.getOkHttpClient())
                    .addConverterFactory(getGsonConverterFactory())
                    .addConverterFactory(getEnumConverterFactory())
                    .baseUrl(Constants.HUMMINGBIRD_URL)
                    .build();
        }

        return sHummingbirdRetrofit;
    }

    private static <E extends Enum<E>> String getSerializedName(final E e) {
        try {
            return e.getClass().getField(e.name()).getAnnotation(SerializedName.class).value();
        } catch (final NoSuchFieldException e1) {
            return e.name();
        }
    }

    public static synchronized WebsiteApi getWebsiteApi() {
        if (sWebsiteApi == null) {
            Timber.d(TAG, "creating Website Api instance");
            final Retrofit retrofit = getWebsiteRetrofit();
            sWebsiteApi = retrofit.create(WebsiteApi.class);
        }

        return sWebsiteApi;
    }

    public static synchronized Retrofit getWebsiteRetrofit() {
        if (sWebsiteRetrofit == null) {
            Timber.d(TAG, "creating Website Retrofit instance");
            sWebsiteRetrofit = new Retrofit.Builder()
                    .client(OkHttpUtils.getOkHttpClient())
                    .addConverterFactory(getGsonConverterFactory())
                    .addConverterFactory(getEnumConverterFactory())
                    .baseUrl(Constants.WEBSITE_URL)
                    .build();
        }

        return sWebsiteRetrofit;
    }
{'fraction_non_alphanumeric': 0.0799623706491063, 'fraction_numerical': 0.0012543116964565694, 'mean_word_length': 2.6936884771279677, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6650684', 'n_tokens_mistral': 1800, 'n_tokens_neox': 1698, 'n_words': 344}