Skip to content

Commit

Permalink
feat: add Patch#dependsOn extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Sculas committed Jul 31, 2022
1 parent 4813a8b commit 523f67b
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -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 {
Expand Down

0 comments on commit 523f67b

Please sign in to comment.