2023-02-19 06:03:30 -08:00
|
|
|
package co.electriccoin.zcash.configuration.model.map
|
|
|
|
|
|
|
|
import co.electriccoin.zcash.configuration.model.entry.ConfigKey
|
|
|
|
import kotlinx.datetime.Instant
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An immutable snapshot of a key-value configuration.
|
|
|
|
*/
|
|
|
|
interface Configuration {
|
|
|
|
/**
|
2023-06-18 23:59:00 -07:00
|
|
|
* @return When the configuration was updated. Null indicates the configuration either doesn't refresh or has
|
|
|
|
* never been refreshed.
|
2023-02-19 06:03:30 -08:00
|
|
|
*/
|
|
|
|
val updatedAt: Instant?
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param key Key to check.
|
|
|
|
* @return True if a mapping for `key` exists.
|
|
|
|
*/
|
|
|
|
fun hasKey(key: ConfigKey): Boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param key Key to use to retrieve the value.
|
|
|
|
* @param defaultValue Value to use if `key` doesn't exist in the
|
|
|
|
* configuration. Some implementations may not use strong types, and the default can also
|
|
|
|
* be returned if type coercion fails.
|
|
|
|
* @return boolean mapping for `key` or `defaultValue`.
|
|
|
|
*/
|
2023-12-11 01:20:32 -08:00
|
|
|
fun getBoolean(
|
|
|
|
key: ConfigKey,
|
|
|
|
defaultValue: Boolean
|
|
|
|
): Boolean
|
2023-02-19 06:03:30 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param key Key to use to retrieve the value.
|
|
|
|
* @param defaultValue Value to use if `key` doesn't exist in the
|
|
|
|
* configuration. Some implementations may not use strong types, and the default can also
|
|
|
|
* be returned if type coercion fails.
|
|
|
|
* @return int mapping for `key` or `defaultValue`.
|
|
|
|
*/
|
2023-12-11 01:20:32 -08:00
|
|
|
fun getInt(
|
|
|
|
key: ConfigKey,
|
|
|
|
defaultValue: Int
|
|
|
|
): Int
|
2023-02-19 06:03:30 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param key Key to use to retrieve the value.
|
|
|
|
* @param defaultValue Value to use if `key` doesn't exist in the
|
|
|
|
* configuration. Some implementations may not use strong types, and the default can also
|
|
|
|
* be returned if type coercion fails.
|
|
|
|
* @return String mapping for `key` or `defaultValue`.
|
|
|
|
*/
|
2023-12-11 01:20:32 -08:00
|
|
|
fun getString(
|
|
|
|
key: ConfigKey,
|
|
|
|
defaultValue: String
|
|
|
|
): String
|
2023-02-19 06:03:30 -08:00
|
|
|
}
|