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