Skip to content

Commit

Permalink
feat: Make PatchOption#values nullable
Browse files Browse the repository at this point in the history
There is no difference semantically, but this change allows passing null as a parameter which is simpler than having to use `emptySet()`.
  • Loading branch information
oSumAtrIX committed Oct 22, 2023
1 parent 1b52e4b commit 56ce9ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import kotlin.reflect.KProperty
open class PatchOption<T>(
val key: String,
val default: T?,
val values: Set<T>,
val values: Set<T>?,
val title: String?,
val description: String?,
val required: Boolean,
Expand Down Expand Up @@ -105,7 +105,7 @@ open class PatchOption<T>(
fun <P : Patch<*>> P.stringPatchOption(
key: String,
default: String? = null,
values: Set<String> = emptySet(),
values: Set<String>? = null,
title: String? = null,
description: String? = null,
required: Boolean = false,
Expand All @@ -130,7 +130,7 @@ open class PatchOption<T>(
fun <P : Patch<*>> P.intPatchOption(
key: String,
default: Int? = null,
values: Set<Int> = emptySet(),
values: Set<Int>? = null,
title: String? = null,
description: String? = null,
required: Boolean = false,
Expand All @@ -155,7 +155,7 @@ open class PatchOption<T>(
fun <P : Patch<*>> P.booleanPatchOption(
key: String,
default: Boolean? = null,
values: Set<Boolean> = emptySet(),
values: Set<Boolean>? = null,
title: String? = null,
description: String? = null,
required: Boolean = false,
Expand All @@ -180,7 +180,7 @@ open class PatchOption<T>(
fun <P : Patch<*>> P.floatPatchOption(
key: String,
default: Float? = null,
values: Set<Float> = emptySet(),
values: Set<Float>? = null,
title: String? = null,
description: String? = null,
required: Boolean = false,
Expand All @@ -205,7 +205,7 @@ open class PatchOption<T>(
fun <P : Patch<*>> P.longPatchOption(
key: String,
default: Long? = null,
values: Set<Long> = emptySet(),
values: Set<Long>? = null,
title: String? = null,
description: String? = null,
required: Boolean = false,
Expand All @@ -230,7 +230,7 @@ open class PatchOption<T>(
fun <P : Patch<*>> P.stringArrayPatchOption(
key: String,
default: Array<String>? = null,
values: Set<Array<String>> = emptySet(),
values: Set<Array<String>>? = null,
title: String? = null,
description: String? = null,
required: Boolean = false,
Expand All @@ -255,7 +255,7 @@ open class PatchOption<T>(
fun <P : Patch<*>> P.intArrayPatchOption(
key: String,
default: Array<Int>? = null,
values: Set<Array<Int>> = emptySet(),
values: Set<Array<Int>>? = null,
title: String? = null,
description: String? = null,
required: Boolean = false,
Expand All @@ -280,7 +280,7 @@ open class PatchOption<T>(
fun <P : Patch<*>> P.booleanArrayPatchOption(
key: String,
default: Array<Boolean>? = null,
values: Set<Array<Boolean>> = emptySet(),
values: Set<Array<Boolean>>? = null,
title: String? = null,
description: String? = null,
required: Boolean = false,
Expand All @@ -305,7 +305,7 @@ open class PatchOption<T>(
fun <P : Patch<*>> P.floatArrayPatchOption(
key: String,
default: Array<Float>? = null,
values: Set<Array<Float>> = emptySet(),
values: Set<Array<Float>>? = null,
title: String? = null,
description: String? = null,
required: Boolean = false,
Expand All @@ -330,7 +330,7 @@ open class PatchOption<T>(
fun <P : Patch<*>> P.longArrayPatchOption(
key: String,
default: Array<Long>? = null,
values: Set<Array<Long>> = emptySet(),
values: Set<Array<Long>>? = null,
title: String? = null,
description: String? = null,
required: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal class PatchOptionsTest {
@Test
fun `should allow setting value from values`() =
with(OptionsTestPatch.options["choices"] as PatchOption<String>) {
value = values.last()
value = values!!.last()
assertTrue(value == "valid")
}

Expand Down

0 comments on commit 56ce9ec

Please sign in to comment.