refactor: util package structure

This commit is contained in:
Sculas
2022-08-03 18:31:31 +02:00
parent 2572cd04b5
commit 01cf3fb50f
5 changed files with 14 additions and 14 deletions

View File

@@ -5,6 +5,6 @@ import java.io.InputStream
/**
* Wrapper for dex files.
* @param name The original name of the dex file.
* @param dexFileInputStream The dex file as [InputStream].
* @param stream The dex file as [InputStream].
*/
data class DexFile(val name: String, val dexFileInputStream: InputStream)
data class DexFile(val name: String, val stream: InputStream)

View File

@@ -1,17 +1,17 @@
package app.revanced.patcher.util.patch.base
package app.revanced.patcher.util.patch
import app.revanced.patcher.data.Data
import app.revanced.patcher.patch.Patch
import java.io.File
/**
* @param patchBundlePath The path to the patch bundle.
* @param path The path to the patch bundle.
*/
abstract class PatchBundle(patchBundlePath: String) : File(patchBundlePath) {
abstract class PatchBundle(path: String) : File(path) {
internal fun loadPatches(classLoader: ClassLoader, classNames: Iterator<String>) = buildList {
classNames.forEach { className ->
for (className in classNames) {
val clazz = classLoader.loadClass(className)
if (!clazz.isAnnotationPresent(app.revanced.patcher.patch.annotations.Patch::class.java)) return@forEach
if (!clazz.isAnnotationPresent(app.revanced.patcher.patch.annotations.Patch::class.java)) continue
@Suppress("UNCHECKED_CAST") this.add(clazz as Class<out Patch<Data>>)
}
}

View File

@@ -1,4 +1,4 @@
package app.revanced.patcher.util.patch.util
package app.revanced.patcher.util.patch
internal class StringIterator<T, I : Iterator<T>>(
private val iterator: I,

View File

@@ -1,7 +1,7 @@
package app.revanced.patcher.util.patch.implementation
package app.revanced.patcher.util.patch.impl
import app.revanced.patcher.util.patch.base.PatchBundle
import app.revanced.patcher.util.patch.util.StringIterator
import app.revanced.patcher.util.patch.PatchBundle
import app.revanced.patcher.util.patch.StringIterator
import org.jf.dexlib2.DexFileFactory
/**

View File

@@ -1,7 +1,7 @@
package app.revanced.patcher.util.patch.implementation
package app.revanced.patcher.util.patch.impl
import app.revanced.patcher.util.patch.base.PatchBundle
import app.revanced.patcher.util.patch.util.StringIterator
import app.revanced.patcher.util.patch.PatchBundle
import app.revanced.patcher.util.patch.StringIterator
import java.net.URLClassLoader
import java.util.jar.JarFile