feat: add Patch#dependsOn extension

This commit is contained in:
Sculas 2022-07-31 15:07:23 +02:00
parent 4813a8b48e
commit 523f67b238
No known key found for this signature in database
GPG key ID: 1530BFF96D1EEB89

View file

@ -36,13 +36,18 @@ private fun <T : Annotation> Class<*>.findAnnotationRecursively(
}
object PatchExtensions {
val Class<out Patch<Data>>.patchName: String
get() = recursiveAnnotation(Name::class)?.name ?: this.javaClass.simpleName
val Class<out Patch<Data>>.patchName: String get() = recursiveAnnotation(Name::class)?.name ?: this.javaClass.simpleName
val Class<out Patch<Data>>.version get() = recursiveAnnotation(Version::class)?.version
val Class<out Patch<Data>>.include get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.Patch::class)!!.include
val Class<out Patch<Data>>.description get() = recursiveAnnotation(Description::class)?.description
val Class<out Patch<Data>>.dependencies get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.Dependencies::class)?.dependencies
val Class<out Patch<Data>>.compatiblePackages get() = recursiveAnnotation(Compatibility::class)?.compatiblePackages
@JvmStatic
fun Class<out Patch<Data>>.dependsOn(patch: Class<out Patch<Data>>): Boolean {
if (this.patchName == patch.patchName) throw IllegalArgumentException("thisval and patch may not be the same")
return this.dependencies?.any { it.java.patchName == this@dependsOn.patchName } == true
}
}
object MethodFingerprintExtensions {