feat: Name patch option value validator property correctly

BREAKING CHANGE: This changes the getter name of the property.
This commit is contained in:
oSumAtrIX 2023-10-21 23:51:44 +02:00
parent f28bfe0dbd
commit caa634fac6
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
12 changed files with 62 additions and 62 deletions

View file

@ -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

View file

@ -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<T>(
@ -19,7 +19,7 @@ abstract class PatchOption<T>(
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<T>(
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
}

View file

@ -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<Boolean>(key, default, title, description, required, validate) {
validator: (Boolean?) -> Boolean
) : PatchOption<Boolean>(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) }
}
}

View file

@ -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<Float>(key, default, title, description, required, validate) {
validator: (Float?) -> Boolean
) : PatchOption<Float>(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) }
}
}

View file

@ -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<Int>(key, default, title, description, required, validate) {
validator: (Int?) -> Boolean
) : PatchOption<Int>(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) }
}
}

View file

@ -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<Long>(key, default, title, description, required, validate) {
validator: (Long?) -> Boolean
) : PatchOption<Long>(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) }
}
}

View file

@ -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<String>(key, default, title, description, required, validate) {
validator: (String?) -> Boolean
) : PatchOption<String>(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) }
}
}

View file

@ -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>?) -> Boolean
) : PatchOption<Array<Boolean>>(key, default, title, description, required, validate) {
validator: (Array<Boolean>?) -> Boolean
) : PatchOption<Array<Boolean>>(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>?) -> Boolean = { true }
) = BooleanArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) }
validator: (Array<Boolean>?) -> Boolean = { true }
) = BooleanArrayPatchOption(key, default, title, description, required, validator).also { options.register(it) }
}
}

View file

@ -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<Float>?) -> Boolean
) : PatchOption<Array<Float>>(key, default, title, description, required, validate) {
validator: (Array<Float>?) -> Boolean
) : PatchOption<Array<Float>>(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<Float>?) -> Boolean = { true }
) = FloatArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) }
validator: (Array<Float>?) -> Boolean = { true }
) = FloatArrayPatchOption(key, default, title, description, required, validator).also { options.register(it) }
}
}

View file

@ -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<Int>?) -> Boolean
) : PatchOption<Array<Int>>(key, default, title, description, required, validate) {
validator: (Array<Int>?) -> Boolean
) : PatchOption<Array<Int>>(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<Int>?) -> Boolean = { true }
) = IntArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) }
validator: (Array<Int>?) -> Boolean = { true }
) = IntArrayPatchOption(key, default, title, description, required, validator).also { options.register(it) }
}
}

View file

@ -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<Long>?) -> Boolean
) : PatchOption<Array<Long>>(key, default, title, description, required, validate) {
validator: (Array<Long>?) -> Boolean
) : PatchOption<Array<Long>>(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<Long>?) -> Boolean = { true }
) = LongArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) }
validator: (Array<Long>?) -> Boolean = { true }
) = LongArrayPatchOption(key, default, title, description, required, validator).also { options.register(it) }
}
}

View file

@ -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<String>?) -> Boolean
) : PatchOption<Array<String>>(key, default, title, description, required, validate) {
validator: (Array<String>?) -> Boolean
) : PatchOption<Array<String>>(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<String>?) -> Boolean = { true }
) = StringArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) }
validator: (Array<String>?) -> Boolean = { true }
) = StringArrayPatchOption(key, default, title, description, required, validator).also { options.register(it) }
}
}