mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-28 12:30:12 +02:00
perf: mapping manager
This commit is contained in:
parent
3dafa28f31
commit
6f97584622
@ -10,6 +10,7 @@ class GridMediaItemMapper : Mapper() {
|
||||
mappings: MutableMap<String, Any>
|
||||
) {
|
||||
for (clazz in classes) {
|
||||
if (clazz.isEnum || clazz.isInterface) continue
|
||||
if (clazz.annotations.isEmpty()) continue
|
||||
if (!clazz.annotations[0].toString().contains("typeReferences")) continue
|
||||
clazz.declaredFields.firstOrNull {
|
||||
|
@ -6,6 +6,7 @@ import java.lang.reflect.Method
|
||||
|
||||
|
||||
class PlusSubscriptionMapper : Mapper() {
|
||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||
override fun useClasses(
|
||||
classLoader: ClassLoader,
|
||||
classes: List<Class<*>>,
|
||||
@ -30,8 +31,8 @@ class PlusSubscriptionMapper : Mapper() {
|
||||
|
||||
val members = mutableMapOf<String, Any>()
|
||||
loadSubscriptionMethod.returnType.declaredFields.forEach { field ->
|
||||
val serializedNameAnnotation = field.declaredAnnotations.first()
|
||||
val propertyName = serializedNameAnnotation.annotationClass.members.first { it.name == "name" }.call(serializedNameAnnotation) as String
|
||||
val serializedNameAnnotation = (field.declaredAnnotations.first() as java.lang.annotation.Annotation)
|
||||
val propertyName = serializedNameAnnotation.annotationType().getDeclaredMethod("name").also { it.isAccessible = true }.invoke(serializedNameAnnotation) as String
|
||||
members[propertyName] = field.name
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user