package com.kfzs.duanduan.datashare;

import android.text.TextUtils;

/**
 * <pre>
 *     sinlov
 *
 *     /\__/\
 *    /`    '\
 *  ≈≈≈ 0  0 ≈≈≈ Hello world!
 *    \  --  /
 *   /        \
 *  /          \
 * |            |
 *  \  ||  ||  /
 *   \_oo__oo_/≡≡≡≡≡≡≡≡o
 *
 * </pre>
 * Created by sinlov on 17/3/10.
 */
public class BuildConfigSaver {
    private static BuildConfigSaver instance;
    private String flavor;
    private String datashare;
    private String graph;

    public String getDatashare() {
        if (TextUtils.isEmpty(datashare)) {
            datashare = BuildConfigUtils.getBuildConfigByKey("DUANDUAN_DATASHARE");
            if (TextUtils.isEmpty(datashare)) {
                throw new IllegalArgumentException("you are not setting buildConfigField \"String\", \"DUANDUAN_DATASHARE\", '\"debug\"' ");
            }
        }
        return datashare;
    }

    public String getGraph() {
        if (TextUtils.isEmpty(graph)) {
            graph = BuildConfigUtils.getBuildConfigByKey("DUANDUAN_GRAPH");
            if (TextUtils.isEmpty(graph)) {
                throw new IllegalArgumentException("you are not setting buildConfigField \"String\", \"DUANDUAN_GRAPH\", '\"debug\"' ");
            }
        }
        return graph;
    }

    public String getFlavor() {
        if (TextUtils.isEmpty(flavor)) {
            flavor = BuildConfigUtils.getBuildConfigByKey("FLAVOR");
            return flavor;
        } else {
            return flavor;
        }
    }

    public static BuildConfigSaver getInstance() {
        if (instance == null) {
            instance = new BuildConfigSaver();
        }
        return instance;
    }

    private BuildConfigSaver() {
    }
}
