Commit 03a6b079 authored by Mygod's avatar Mygod

New helper method: PluginOptions.putWithDefault

parent c474221d
* 1.1.0: * 1.1.0:
* New helper method: `PluginOptions.putWithDefault`.
* 1.0.0: * 1.0.0:
* `PathProvider` now takes `Int` instead of `String` for file modes; * `PathProvider` now takes `Int` instead of `String` for file modes;
* Refactor to AndroidX; * Refactor to AndroidX;
......
...@@ -68,6 +68,14 @@ class PluginOptions : HashMap<String, String?> { ...@@ -68,6 +68,14 @@ class PluginOptions : HashMap<String, String?> {
this.id = id this.id = id
} }
/**
* Put but if value is null or default, the entry is deleted.
*
* @return Old value before put.
*/
fun putWithDefault(key: String, value: String?, default: String? = null) =
if (value == null || value == default) remove(key) else put(key, value)
private fun append(result: StringBuilder, str: String) = (0 until str.length) private fun append(result: StringBuilder, str: String) = (0 until str.length)
.map { str[it] } .map { str[it] }
.forEach { .forEach {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment