package com.doverfuelingsolutions.issp.data

import com.doverfuelingsolutions.issp.utils.sp.SPUtil

class GlobalDataProvider(defaultValue: String, private val sp: String = "") {

    private var value = defaultValue
    private var isInit = false

    fun get(): String {
        if (sp.isNotEmpty() && !isInit) {
            isInit = true
            value = SPUtil.getString(sp, value)
        }
        return value
    }

    fun set(v: String) {
        value = v
        if (sp.isNotEmpty()) {
            SPUtil.putString(sp, v)
        }
    }
}