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 getKey ()Ljava/lang/String;
public final fun getRequired ()Z public final fun getRequired ()Z
public final fun getTitle ()Ljava/lang/String; 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;
public final fun getValue (Ljava/lang/Object;Lkotlin/reflect/KProperty;)Ljava/lang/Object; public final fun getValue (Ljava/lang/Object;Lkotlin/reflect/KProperty;)Ljava/lang/Object;
public final fun setValue (Ljava/lang/Object;)V public final fun setValue (Ljava/lang/Object;)V

View file

@ -10,7 +10,7 @@ import kotlin.reflect.KProperty
* @param title The title. * @param title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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. * @param T The value type of the option.
*/ */
abstract class PatchOption<T>( abstract class PatchOption<T>(
@ -19,7 +19,7 @@ abstract class PatchOption<T>(
val title: String?, val title: String?,
val description: String?, val description: String?,
val required: Boolean, val required: Boolean,
val validate: (T?) -> Boolean val validator: (T?) -> Boolean
) { ) {
/** /**
* The value of the [PatchOption]. * The value of the [PatchOption].
@ -27,7 +27,7 @@ abstract class PatchOption<T>(
var value: T? = default var value: T? = default
set(value) { set(value) {
if (required && value == null) throw PatchOptionException.ValueRequiredException(this) 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 field = value
} }

View file

@ -11,7 +11,7 @@ import app.revanced.patcher.patch.options.PatchOption
* @param title The title. * @param title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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 * @see PatchOption
*/ */
@ -21,8 +21,8 @@ class BooleanPatchOption private constructor(
title: String?, title: String?,
description: String?, description: String?,
required: Boolean, required: Boolean,
validate: (Boolean?) -> Boolean validator: (Boolean?) -> Boolean
) : PatchOption<Boolean>(key, default, title, description, required, validate) { ) : PatchOption<Boolean>(key, default, title, description, required, validator) {
companion object { companion object {
/** /**
* Create a new [BooleanPatchOption] and add it to the current [Patch]. * Create a new [BooleanPatchOption] and add it to the current [Patch].
@ -43,7 +43,7 @@ class BooleanPatchOption private constructor(
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
required: Boolean = false, required: Boolean = false,
validate: (Boolean?) -> Boolean = { true } validator: (Boolean?) -> Boolean = { true }
) = BooleanPatchOption(key, default, title, description, required, validate).also { options.register(it) } ) = 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 title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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 * @see PatchOption
*/ */
@ -21,8 +21,8 @@ class FloatPatchOption private constructor(
title: String?, title: String?,
description: String?, description: String?,
required: Boolean, required: Boolean,
validate: (Float?) -> Boolean validator: (Float?) -> Boolean
) : PatchOption<Float>(key, default, title, description, required, validate) { ) : PatchOption<Float>(key, default, title, description, required, validator) {
companion object { companion object {
/** /**
* Create a new [FloatPatchOption] and add it to the current [Patch]. * Create a new [FloatPatchOption] and add it to the current [Patch].
@ -32,7 +32,7 @@ class FloatPatchOption private constructor(
* @param title The title. * @param title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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]. * @return The created [FloatPatchOption].
* *
@ -45,7 +45,7 @@ class FloatPatchOption private constructor(
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
required: Boolean = false, required: Boolean = false,
validate: (Float?) -> Boolean = { true } validator: (Float?) -> Boolean = { true }
) = FloatPatchOption(key, default, title, description, required, validate).also { options.register(it) } ) = 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 title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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 * @see PatchOption
*/ */
@ -21,8 +21,8 @@ class IntPatchOption private constructor(
title: String?, title: String?,
description: String?, description: String?,
required: Boolean, required: Boolean,
validate: (Int?) -> Boolean validator: (Int?) -> Boolean
) : PatchOption<Int>(key, default, title, description, required, validate) { ) : PatchOption<Int>(key, default, title, description, required, validator) {
companion object { companion object {
/** /**
* Create a new [IntPatchOption] and add it to the current [Patch]. * Create a new [IntPatchOption] and add it to the current [Patch].
@ -32,7 +32,7 @@ class IntPatchOption private constructor(
* @param title The title. * @param title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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]. * @return The created [IntPatchOption].
* *
@ -45,7 +45,7 @@ class IntPatchOption private constructor(
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
required: Boolean = false, required: Boolean = false,
validate: (Int?) -> Boolean = { true } validator: (Int?) -> Boolean = { true }
) = IntPatchOption(key, default, title, description, required, validate).also { options.register(it) } ) = 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 title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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 * @see PatchOption
*/ */
@ -21,8 +21,8 @@ class LongPatchOption private constructor(
title: String?, title: String?,
description: String?, description: String?,
required: Boolean, required: Boolean,
validate: (Long?) -> Boolean validator: (Long?) -> Boolean
) : PatchOption<Long>(key, default, title, description, required, validate) { ) : PatchOption<Long>(key, default, title, description, required, validator) {
companion object { companion object {
/** /**
* Create a new [LongPatchOption] and add it to the current [Patch]. * Create a new [LongPatchOption] and add it to the current [Patch].
@ -43,7 +43,7 @@ class LongPatchOption private constructor(
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
required: Boolean = false, required: Boolean = false,
validate: (Long?) -> Boolean = { true } validator: (Long?) -> Boolean = { true }
) = LongPatchOption(key, default, title, description, required, validate).also { options.register(it) } ) = 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 title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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 * @see PatchOption
*/ */
@ -21,8 +21,8 @@ class StringPatchOption private constructor(
title: String?, title: String?,
description: String?, description: String?,
required: Boolean, required: Boolean,
validate: (String?) -> Boolean validator: (String?) -> Boolean
) : PatchOption<String>(key, default, title, description, required, validate) { ) : PatchOption<String>(key, default, title, description, required, validator) {
companion object { companion object {
/** /**
* Create a new [StringPatchOption] and add it to the current [Patch]. * Create a new [StringPatchOption] and add it to the current [Patch].
@ -32,7 +32,7 @@ class StringPatchOption private constructor(
* @param title The title. * @param title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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]. * @return The created [StringPatchOption].
* *
@ -45,7 +45,7 @@ class StringPatchOption private constructor(
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
required: Boolean = false, required: Boolean = false,
validate: (String?) -> Boolean = { true } validator: (String?) -> Boolean = { true }
) = StringPatchOption(key, default, title, description, required, validate).also { options.register(it) } ) = 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 title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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 * @see PatchOption
*/ */
@ -21,8 +21,8 @@ class BooleanArrayPatchOption private constructor(
title: String?, title: String?,
description: String?, description: String?,
required: Boolean, required: Boolean,
validate: (Array<Boolean>?) -> Boolean validator: (Array<Boolean>?) -> Boolean
) : PatchOption<Array<Boolean>>(key, default, title, description, required, validate) { ) : PatchOption<Array<Boolean>>(key, default, title, description, required, validator) {
companion object { companion object {
/** /**
* Create a new [BooleanArrayPatchOption] and add it to the current [Patch]. * Create a new [BooleanArrayPatchOption] and add it to the current [Patch].
@ -32,7 +32,7 @@ class BooleanArrayPatchOption private constructor(
* @param title The title. * @param title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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]. * @return The created [BooleanArrayPatchOption].
* *
@ -45,7 +45,7 @@ class BooleanArrayPatchOption private constructor(
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
required: Boolean = false, required: Boolean = false,
validate: (Array<Boolean>?) -> Boolean = { true } validator: (Array<Boolean>?) -> Boolean = { true }
) = BooleanArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) } ) = 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 title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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 * @see PatchOption
*/ */
@ -21,8 +21,8 @@ class FloatArrayPatchOption private constructor(
title: String?, title: String?,
description: String?, description: String?,
required: Boolean, required: Boolean,
validate: (Array<Float>?) -> Boolean validator: (Array<Float>?) -> Boolean
) : PatchOption<Array<Float>>(key, default, title, description, required, validate) { ) : PatchOption<Array<Float>>(key, default, title, description, required, validator) {
companion object { companion object {
/** /**
* Create a new [FloatArrayPatchOption] and add it to the current [Patch]. * Create a new [FloatArrayPatchOption] and add it to the current [Patch].
@ -32,7 +32,7 @@ class FloatArrayPatchOption private constructor(
* @param title The title. * @param title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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]. * @return The created [FloatArrayPatchOption].
* *
@ -45,7 +45,7 @@ class FloatArrayPatchOption private constructor(
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
required: Boolean = false, required: Boolean = false,
validate: (Array<Float>?) -> Boolean = { true } validator: (Array<Float>?) -> Boolean = { true }
) = FloatArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) } ) = 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 title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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 * @see PatchOption
*/ */
@ -21,8 +21,8 @@ class IntArrayPatchOption private constructor(
title: String?, title: String?,
description: String?, description: String?,
required: Boolean, required: Boolean,
validate: (Array<Int>?) -> Boolean validator: (Array<Int>?) -> Boolean
) : PatchOption<Array<Int>>(key, default, title, description, required, validate) { ) : PatchOption<Array<Int>>(key, default, title, description, required, validator) {
companion object { companion object {
/** /**
* Create a new [IntArrayPatchOption] and add it to the current [Patch]. * Create a new [IntArrayPatchOption] and add it to the current [Patch].
@ -32,7 +32,7 @@ class IntArrayPatchOption private constructor(
* @param title The title. * @param title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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]. * @return The created [IntArrayPatchOption].
* *
@ -45,7 +45,7 @@ class IntArrayPatchOption private constructor(
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
required: Boolean = false, required: Boolean = false,
validate: (Array<Int>?) -> Boolean = { true } validator: (Array<Int>?) -> Boolean = { true }
) = IntArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) } ) = 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 title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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 * @see PatchOption
*/ */
@ -21,8 +21,8 @@ class LongArrayPatchOption private constructor(
title: String?, title: String?,
description: String?, description: String?,
required: Boolean, required: Boolean,
validate: (Array<Long>?) -> Boolean validator: (Array<Long>?) -> Boolean
) : PatchOption<Array<Long>>(key, default, title, description, required, validate) { ) : PatchOption<Array<Long>>(key, default, title, description, required, validator) {
companion object { companion object {
/** /**
* Create a new [LongArrayPatchOption] and add it to the current [Patch]. * Create a new [LongArrayPatchOption] and add it to the current [Patch].
@ -32,7 +32,7 @@ class LongArrayPatchOption private constructor(
* @param title The title. * @param title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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]. * @return The created [LongArrayPatchOption].
* *
@ -45,7 +45,7 @@ class LongArrayPatchOption private constructor(
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
required: Boolean = false, required: Boolean = false,
validate: (Array<Long>?) -> Boolean = { true } validator: (Array<Long>?) -> Boolean = { true }
) = LongArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) } ) = 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 title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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 * @see PatchOption
*/ */
@ -21,8 +21,8 @@ class StringArrayPatchOption private constructor(
title: String?, title: String?,
description: String?, description: String?,
required: Boolean, required: Boolean,
validate: (Array<String>?) -> Boolean validator: (Array<String>?) -> Boolean
) : PatchOption<Array<String>>(key, default, title, description, required, validate) { ) : PatchOption<Array<String>>(key, default, title, description, required, validator) {
companion object { companion object {
/** /**
* Create a new [StringArrayPatchOption] and add it to the current [Patch]. * Create a new [StringArrayPatchOption] and add it to the current [Patch].
@ -32,7 +32,7 @@ class StringArrayPatchOption private constructor(
* @param title The title. * @param title The title.
* @param description A description. * @param description A description.
* @param required Whether the option is required. * @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]. * @return The created [StringArrayPatchOption].
* *
@ -45,7 +45,7 @@ class StringArrayPatchOption private constructor(
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
required: Boolean = false, required: Boolean = false,
validate: (Array<String>?) -> Boolean = { true } validator: (Array<String>?) -> Boolean = { true }
) = StringArrayPatchOption(key, default, title, description, required, validate).also { options.register(it) } ) = StringArrayPatchOption(key, default, title, description, required, validator).also { options.register(it) }
} }
} }