diff --git a/api/revanced-patcher.api b/api/revanced-patcher.api index d727f2d..c4eefa4 100644 --- a/api/revanced-patcher.api +++ b/api/revanced-patcher.api @@ -366,7 +366,7 @@ public abstract class app/revanced/patcher/patch/options/PatchOption { public final fun getKey ()Ljava/lang/String; public final fun getRequired ()Z public final fun getTitle ()Ljava/lang/String; - public final fun getValidate ()Lkotlin/jvm/functions/Function1; + public final fun getValidator ()Lkotlin/jvm/functions/Function1; public final fun getValue ()Ljava/lang/Object; public final fun getValue (Ljava/lang/Object;Lkotlin/reflect/KProperty;)Ljava/lang/Object; public final fun setValue (Ljava/lang/Object;)V 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 df130bf..35daaff 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/PatchOption.kt @@ -10,7 +10,7 @@ import kotlin.reflect.KProperty * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * @param T The value type of the option. */ abstract class PatchOption( @@ -19,7 +19,7 @@ abstract class PatchOption( val title: String?, val description: String?, val required: Boolean, - val validate: (T?) -> Boolean + val validator: (T?) -> Boolean ) { /** * The value of the [PatchOption]. @@ -27,7 +27,7 @@ abstract class PatchOption( var value: T? = default set(value) { if (required && value == null) throw PatchOptionException.ValueRequiredException(this) - if (!validate(value)) throw PatchOptionException.ValueValidationException(value, this) + if (!validator(value)) throw PatchOptionException.ValueValidationException(value, this) field = value } diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/types/BooleanPatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/types/BooleanPatchOption.kt index 7d808cd..b2941dd 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/types/BooleanPatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/types/BooleanPatchOption.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.options.PatchOption * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @see PatchOption */ @@ -21,8 +21,8 @@ class BooleanPatchOption private constructor( title: String?, description: String?, required: Boolean, - validate: (Boolean?) -> Boolean -) : PatchOption(key, default, title, description, required, validate) { + validator: (Boolean?) -> Boolean +) : PatchOption(key, default, title, description, required, validator) { companion object { /** * Create a new [BooleanPatchOption] and add it to the current [Patch]. @@ -43,7 +43,7 @@ class BooleanPatchOption private constructor( title: String? = null, description: String? = null, required: Boolean = false, - validate: (Boolean?) -> Boolean = { true } - ) = BooleanPatchOption(key, default, title, description, required, validate).also { options.register(it) } + validator: (Boolean?) -> Boolean = { true } + ) = BooleanPatchOption(key, default, title, description, required, validator).also { options.register(it) } } } diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/types/FloatPatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/types/FloatPatchOption.kt index 6beb874..7e89774 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/types/FloatPatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/types/FloatPatchOption.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.options.PatchOption * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @see PatchOption */ @@ -21,8 +21,8 @@ class FloatPatchOption private constructor( title: String?, description: String?, required: Boolean, - validate: (Float?) -> Boolean -) : PatchOption(key, default, title, description, required, validate) { + validator: (Float?) -> Boolean +) : PatchOption(key, default, title, description, required, validator) { companion object { /** * Create a new [FloatPatchOption] and add it to the current [Patch]. @@ -32,7 +32,7 @@ class FloatPatchOption private constructor( * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @return The created [FloatPatchOption]. * @@ -45,7 +45,7 @@ class FloatPatchOption private constructor( title: String? = null, description: String? = null, required: Boolean = false, - validate: (Float?) -> Boolean = { true } - ) = FloatPatchOption(key, default, title, description, required, validate).also { options.register(it) } + validator: (Float?) -> Boolean = { true } + ) = FloatPatchOption(key, default, title, description, required, validator).also { options.register(it) } } } diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/types/IntPatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/types/IntPatchOption.kt index 21f5344..4b500f3 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/types/IntPatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/types/IntPatchOption.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.options.PatchOption * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @see PatchOption */ @@ -21,8 +21,8 @@ class IntPatchOption private constructor( title: String?, description: String?, required: Boolean, - validate: (Int?) -> Boolean -) : PatchOption(key, default, title, description, required, validate) { + validator: (Int?) -> Boolean +) : PatchOption(key, default, title, description, required, validator) { companion object { /** * Create a new [IntPatchOption] and add it to the current [Patch]. @@ -32,7 +32,7 @@ class IntPatchOption private constructor( * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @return The created [IntPatchOption]. * @@ -45,7 +45,7 @@ class IntPatchOption private constructor( title: String? = null, description: String? = null, required: Boolean = false, - validate: (Int?) -> Boolean = { true } - ) = IntPatchOption(key, default, title, description, required, validate).also { options.register(it) } + validator: (Int?) -> Boolean = { true } + ) = IntPatchOption(key, default, title, description, required, validator).also { options.register(it) } } } diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/types/LongPatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/types/LongPatchOption.kt index 15702d0..33e8e08 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/types/LongPatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/types/LongPatchOption.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.options.PatchOption * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @see PatchOption */ @@ -21,8 +21,8 @@ class LongPatchOption private constructor( title: String?, description: String?, required: Boolean, - validate: (Long?) -> Boolean -) : PatchOption(key, default, title, description, required, validate) { + validator: (Long?) -> Boolean +) : PatchOption(key, default, title, description, required, validator) { companion object { /** * Create a new [LongPatchOption] and add it to the current [Patch]. @@ -43,7 +43,7 @@ class LongPatchOption private constructor( title: String? = null, description: String? = null, required: Boolean = false, - validate: (Long?) -> Boolean = { true } - ) = LongPatchOption(key, default, title, description, required, validate).also { options.register(it) } + validator: (Long?) -> Boolean = { true } + ) = LongPatchOption(key, default, title, description, required, validator).also { options.register(it) } } } diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/types/StringPatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/types/StringPatchOption.kt index dc21c74..31cc6b4 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/types/StringPatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/types/StringPatchOption.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.options.PatchOption * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @see PatchOption */ @@ -21,8 +21,8 @@ class StringPatchOption private constructor( title: String?, description: String?, required: Boolean, - validate: (String?) -> Boolean -) : PatchOption(key, default, title, description, required, validate) { + validator: (String?) -> Boolean +) : PatchOption(key, default, title, description, required, validator) { companion object { /** * Create a new [StringPatchOption] and add it to the current [Patch]. @@ -32,7 +32,7 @@ class StringPatchOption private constructor( * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @return The created [StringPatchOption]. * @@ -45,7 +45,7 @@ class StringPatchOption private constructor( title: String? = null, description: String? = null, required: Boolean = false, - validate: (String?) -> Boolean = { true } - ) = StringPatchOption(key, default, title, description, required, validate).also { options.register(it) } + validator: (String?) -> Boolean = { true } + ) = StringPatchOption(key, default, title, description, required, validator).also { options.register(it) } } } diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/types/array/BooleanArrayPatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/types/array/BooleanArrayPatchOption.kt index 52dceaf..6f3dff2 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/types/array/BooleanArrayPatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/types/array/BooleanArrayPatchOption.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.options.PatchOption * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @see PatchOption */ @@ -21,8 +21,8 @@ class BooleanArrayPatchOption private constructor( title: String?, description: String?, required: Boolean, - validate: (Array?) -> Boolean -) : PatchOption>(key, default, title, description, required, validate) { + validator: (Array?) -> Boolean +) : PatchOption>(key, default, title, description, required, validator) { companion object { /** * Create a new [BooleanArrayPatchOption] and add it to the current [Patch]. @@ -32,7 +32,7 @@ class BooleanArrayPatchOption private constructor( * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @return The created [BooleanArrayPatchOption]. * @@ -45,7 +45,7 @@ class BooleanArrayPatchOption private constructor( title: String? = null, description: String? = null, required: Boolean = false, - validate: (Array?) -> Boolean = { true } - ) = BooleanArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) } + validator: (Array?) -> Boolean = { true } + ) = BooleanArrayPatchOption(key, default, title, description, required, validator).also { options.register(it) } } } diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/types/array/FloatArrayPatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/types/array/FloatArrayPatchOption.kt index 83d950e..890f909 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/types/array/FloatArrayPatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/types/array/FloatArrayPatchOption.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.options.PatchOption * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @see PatchOption */ @@ -21,8 +21,8 @@ class FloatArrayPatchOption private constructor( title: String?, description: String?, required: Boolean, - validate: (Array?) -> Boolean -) : PatchOption>(key, default, title, description, required, validate) { + validator: (Array?) -> Boolean +) : PatchOption>(key, default, title, description, required, validator) { companion object { /** * Create a new [FloatArrayPatchOption] and add it to the current [Patch]. @@ -32,7 +32,7 @@ class FloatArrayPatchOption private constructor( * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @return The created [FloatArrayPatchOption]. * @@ -45,7 +45,7 @@ class FloatArrayPatchOption private constructor( title: String? = null, description: String? = null, required: Boolean = false, - validate: (Array?) -> Boolean = { true } - ) = FloatArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) } + validator: (Array?) -> Boolean = { true } + ) = FloatArrayPatchOption(key, default, title, description, required, validator).also { options.register(it) } } } diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/types/array/IntArrayPatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/types/array/IntArrayPatchOption.kt index 18d8a2d..dff47d5 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/types/array/IntArrayPatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/types/array/IntArrayPatchOption.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.options.PatchOption * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @see PatchOption */ @@ -21,8 +21,8 @@ class IntArrayPatchOption private constructor( title: String?, description: String?, required: Boolean, - validate: (Array?) -> Boolean -) : PatchOption>(key, default, title, description, required, validate) { + validator: (Array?) -> Boolean +) : PatchOption>(key, default, title, description, required, validator) { companion object { /** * Create a new [IntArrayPatchOption] and add it to the current [Patch]. @@ -32,7 +32,7 @@ class IntArrayPatchOption private constructor( * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @return The created [IntArrayPatchOption]. * @@ -45,7 +45,7 @@ class IntArrayPatchOption private constructor( title: String? = null, description: String? = null, required: Boolean = false, - validate: (Array?) -> Boolean = { true } - ) = IntArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) } + validator: (Array?) -> Boolean = { true } + ) = IntArrayPatchOption(key, default, title, description, required, validator).also { options.register(it) } } } diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/types/array/LongArrayPatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/types/array/LongArrayPatchOption.kt index 93a7ad8..0b6ad8f 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/types/array/LongArrayPatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/types/array/LongArrayPatchOption.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.options.PatchOption * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @see PatchOption */ @@ -21,8 +21,8 @@ class LongArrayPatchOption private constructor( title: String?, description: String?, required: Boolean, - validate: (Array?) -> Boolean -) : PatchOption>(key, default, title, description, required, validate) { + validator: (Array?) -> Boolean +) : PatchOption>(key, default, title, description, required, validator) { companion object { /** * Create a new [LongArrayPatchOption] and add it to the current [Patch]. @@ -32,7 +32,7 @@ class LongArrayPatchOption private constructor( * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @return The created [LongArrayPatchOption]. * @@ -45,7 +45,7 @@ class LongArrayPatchOption private constructor( title: String? = null, description: String? = null, required: Boolean = false, - validate: (Array?) -> Boolean = { true } - ) = LongArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) } + validator: (Array?) -> Boolean = { true } + ) = LongArrayPatchOption(key, default, title, description, required, validator).also { options.register(it) } } } diff --git a/src/main/kotlin/app/revanced/patcher/patch/options/types/array/StringArrayPatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/options/types/array/StringArrayPatchOption.kt index ccab4a1..c5d7c55 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/options/types/array/StringArrayPatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/options/types/array/StringArrayPatchOption.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.options.PatchOption * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @see PatchOption */ @@ -21,8 +21,8 @@ class StringArrayPatchOption private constructor( title: String?, description: String?, required: Boolean, - validate: (Array?) -> Boolean -) : PatchOption>(key, default, title, description, required, validate) { + validator: (Array?) -> Boolean +) : PatchOption>(key, default, title, description, required, validator) { companion object { /** * Create a new [StringArrayPatchOption] and add it to the current [Patch]. @@ -32,7 +32,7 @@ class StringArrayPatchOption private constructor( * @param title The title. * @param description A description. * @param required Whether the option is required. - * @param validate The function to validate values of the option. + * @param validator The function to validator values of the option. * * @return The created [StringArrayPatchOption]. * @@ -45,7 +45,7 @@ class StringArrayPatchOption private constructor( title: String? = null, description: String? = null, required: Boolean = false, - validate: (Array?) -> Boolean = { true } - ) = StringArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) } + validator: (Array?) -> Boolean = { true } + ) = StringArrayPatchOption(key, default, title, description, required, validator).also { options.register(it) } } }