From 56ce9ec2f98ff351c3d42df71b49e5c88f07e665 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 22 Oct 2023 16:07:01 +0200 Subject: [PATCH] feat: Make `PatchOption#values` nullable There is no difference semantically, but this change allows passing null as a parameter which is simpler than having to use `emptySet()`. --- .../patcher/patch/options/PatchOption.kt | 22 +++++++++---------- .../patcher/patch/options/PatchOptionsTest.kt | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt index 20bd846d..9d0c2fd5 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt @@ -19,7 +19,7 @@ import kotlin.reflect.KProperty open class PatchOption( val key: String, val default: T?, - val values: Set, + val values: Set?, val title: String?, val description: String?, val required: Boolean, @@ -105,7 +105,7 @@ open class PatchOption( fun

> P.stringPatchOption( key: String, default: String? = null, - values: Set = emptySet(), + values: Set? = null, title: String? = null, description: String? = null, required: Boolean = false, @@ -130,7 +130,7 @@ open class PatchOption( fun

> P.intPatchOption( key: String, default: Int? = null, - values: Set = emptySet(), + values: Set? = null, title: String? = null, description: String? = null, required: Boolean = false, @@ -155,7 +155,7 @@ open class PatchOption( fun

> P.booleanPatchOption( key: String, default: Boolean? = null, - values: Set = emptySet(), + values: Set? = null, title: String? = null, description: String? = null, required: Boolean = false, @@ -180,7 +180,7 @@ open class PatchOption( fun

> P.floatPatchOption( key: String, default: Float? = null, - values: Set = emptySet(), + values: Set? = null, title: String? = null, description: String? = null, required: Boolean = false, @@ -205,7 +205,7 @@ open class PatchOption( fun

> P.longPatchOption( key: String, default: Long? = null, - values: Set = emptySet(), + values: Set? = null, title: String? = null, description: String? = null, required: Boolean = false, @@ -230,7 +230,7 @@ open class PatchOption( fun

> P.stringArrayPatchOption( key: String, default: Array? = null, - values: Set> = emptySet(), + values: Set>? = null, title: String? = null, description: String? = null, required: Boolean = false, @@ -255,7 +255,7 @@ open class PatchOption( fun

> P.intArrayPatchOption( key: String, default: Array? = null, - values: Set> = emptySet(), + values: Set>? = null, title: String? = null, description: String? = null, required: Boolean = false, @@ -280,7 +280,7 @@ open class PatchOption( fun

> P.booleanArrayPatchOption( key: String, default: Array? = null, - values: Set> = emptySet(), + values: Set>? = null, title: String? = null, description: String? = null, required: Boolean = false, @@ -305,7 +305,7 @@ open class PatchOption( fun

> P.floatArrayPatchOption( key: String, default: Array? = null, - values: Set> = emptySet(), + values: Set>? = null, title: String? = null, description: String? = null, required: Boolean = false, @@ -330,7 +330,7 @@ open class PatchOption( fun

> P.longArrayPatchOption( key: String, default: Array? = null, - values: Set> = emptySet(), + values: Set>? = null, title: String? = null, description: String? = null, required: Boolean = false, diff --git a/src/test/kotlin/app/revanced/patcher/patch/options/PatchOptionsTest.kt b/src/test/kotlin/app/revanced/patcher/patch/options/PatchOptionsTest.kt index b008bcb5..2cf04eef 100644 --- a/src/test/kotlin/app/revanced/patcher/patch/options/PatchOptionsTest.kt +++ b/src/test/kotlin/app/revanced/patcher/patch/options/PatchOptionsTest.kt @@ -62,7 +62,7 @@ internal class PatchOptionsTest { @Test fun `should allow setting value from values`() = with(OptionsTestPatch.options["choices"] as PatchOption) { - value = values.last() + value = values!!.last() assertTrue(value == "valid") }