package com.tofly.latte_core.config;

import android.content.Context;
import android.os.Handler;

/**
 * 配置管理工具类
 */
public final class Latte {

    public static Configurator init(Context context) {
        getConfigurator().getLatteConfigs().put(ConfigKeys.APPLICATION.name(), context.getApplicationContext());
        return getConfigurator();
    }

    private static Configurator getConfigurator() {
        return Configurator.getInstance();
    }

    //获取配置项
    public static <T> T getConfiguration(Object key) {
        return getConfigurator().getConfiguration(key);
    }

    public static Context getApplicationContext() {
        return (Context) getConfigurator().getLatteConfigs().get(ConfigKeys.APPLICATION.name());
    }

    public static Handler getHandler() {
        return (Handler) getConfigurator().getLatteConfigs().get(ConfigKeys.HANDLE.name());
    }
}
