diff options
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt')
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt index 2f8a6aa..a45d66d 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt @@ -42,6 +42,12 @@ open class KPref private constructor( internal val prefMap: MutableMap<String, ILazyResettable<*>> = mutableMapOf() + fun add(entry : KPrefDelegate<*>) { + if (prefMap.containsKey(entry.key)) + throw KPrefException("${entry.key} is already used elsewhere in preference $preferenceName") + prefMap[entry.key] = entry + } + fun reset() { prefMap.values.forEach { it.invalidate() } } |