mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-03 14:14:26 +02:00
refactor: Do not reify generic type
This commit is contained in:
parent
67b7dff67a
commit
81d1d7f544
@ -407,6 +407,7 @@ public final class app/revanced/patcher/patch/options/PatchOptions : java/util/M
|
|||||||
public final fun remove (Ljava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
public final fun remove (Ljava/lang/Object;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
public final synthetic fun remove (Ljava/lang/Object;)Ljava/lang/Object;
|
public final synthetic fun remove (Ljava/lang/Object;)Ljava/lang/Object;
|
||||||
public fun remove (Ljava/lang/String;)Lapp/revanced/patcher/patch/options/PatchOption;
|
public fun remove (Ljava/lang/String;)Lapp/revanced/patcher/patch/options/PatchOption;
|
||||||
|
public final fun set (Ljava/lang/String;Ljava/lang/Object;)V
|
||||||
public final fun size ()I
|
public final fun size ()I
|
||||||
public final fun values ()Ljava/util/Collection;
|
public final fun values ()Ljava/util/Collection;
|
||||||
}
|
}
|
||||||
|
@ -23,16 +23,18 @@ class PatchOptions internal constructor(
|
|||||||
* @param value The value.
|
* @param value The value.
|
||||||
* @throws PatchOptionException.PatchOptionNotFoundException If the option does not exist.
|
* @throws PatchOptionException.PatchOptionNotFoundException If the option does not exist.
|
||||||
*/
|
*/
|
||||||
inline operator fun <reified T: Any> set(key: String, value: T?) {
|
operator fun <T : Any> set(key: String, value: T?) {
|
||||||
val option = this[key]
|
val option = this[key]
|
||||||
|
|
||||||
if (option.value !is T) throw PatchOptionException.InvalidValueTypeException(
|
try {
|
||||||
T::class.java.name,
|
@Suppress("UNCHECKED_CAST")
|
||||||
option.value?.let { it::class.java.name } ?: "null",
|
(option as PatchOption<T>).value = value
|
||||||
)
|
} catch (e: ClassCastException) {
|
||||||
|
throw PatchOptionException.InvalidValueTypeException(
|
||||||
@Suppress("UNCHECKED_CAST")
|
value?.let { it::class.java.name } ?: "null",
|
||||||
(option as PatchOption<T>).value = value
|
option.value?.let { it::class.java.name } ?: "null",
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user