Skip to content

Commit 9388da4

Browse files
committed
Format ReflectionCache.kt for legibility
1 parent 9e2b007 commit 9388da4

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/ReflectionCache.kt

+20-9
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import kotlin.reflect.jvm.kotlinFunction
1313

1414
internal class ReflectionCache(reflectionCacheSize: Int) {
1515
sealed class BooleanTriState(val value: Boolean?) {
16-
class True: BooleanTriState(true)
17-
class False: BooleanTriState(false)
18-
class Empty: BooleanTriState(null)
16+
class True : BooleanTriState(true)
17+
class False : BooleanTriState(false)
18+
class Empty : BooleanTriState(null)
1919

2020
companion object {
2121
private val TRUE = True()
@@ -40,10 +40,21 @@ internal class ReflectionCache(reflectionCacheSize: Int) {
4040
private val kotlinGeneratedMethod = LRUMap<AnnotatedMethod, Boolean>(reflectionCacheSize, reflectionCacheSize)
4141

4242

43-
fun kotlinFromJava(key: Class<Any>): KClass<Any> = javaClassToKotlin.get(key) ?: key.kotlin.let { javaClassToKotlin.putIfAbsent(key, it) ?: it }
44-
fun kotlinFromJava(key: Constructor<Any>): KFunction<Any>? = javaConstructorToKotlin.get(key) ?: key.kotlinFunction?.let { javaConstructorToKotlin.putIfAbsent(key, it) ?: it }
45-
fun kotlinFromJava(key: Method): KFunction<*>? = javaMethodToKotlin.get(key) ?: key.kotlinFunction?.let { javaMethodToKotlin.putIfAbsent(key, it) ?: it }
46-
fun checkConstructorIsCreatorAnnotated(key: AnnotatedConstructor, calc: (AnnotatedConstructor) -> Boolean): Boolean = javaConstructorIsCreatorAnnotated.get(key) ?: calc(key).let { javaConstructorIsCreatorAnnotated.putIfAbsent(key, it) ?: it }
47-
fun javaMemberIsRequired(key: AnnotatedMember, calc: (AnnotatedMember) -> Boolean?): Boolean? = javaMemberIsRequired.get(key)?.value ?: calc(key).let { javaMemberIsRequired.putIfAbsent(key, BooleanTriState.fromBoolean(it))?.value ?: it }
48-
fun isKotlinGeneratedMethod(key: AnnotatedMethod, calc: (AnnotatedMethod) -> Boolean): Boolean = kotlinGeneratedMethod.get(key) ?: calc(key).let { kotlinGeneratedMethod.putIfAbsent(key, it) ?: it }
43+
fun kotlinFromJava(key: Class<Any>): KClass<Any> = javaClassToKotlin.get(key)
44+
?: key.kotlin.let { javaClassToKotlin.putIfAbsent(key, it) ?: it }
45+
46+
fun kotlinFromJava(key: Constructor<Any>): KFunction<Any>? = javaConstructorToKotlin.get(key)
47+
?: key.kotlinFunction?.let { javaConstructorToKotlin.putIfAbsent(key, it) ?: it }
48+
49+
fun kotlinFromJava(key: Method): KFunction<*>? = javaMethodToKotlin.get(key)
50+
?: key.kotlinFunction?.let { javaMethodToKotlin.putIfAbsent(key, it) ?: it }
51+
52+
fun checkConstructorIsCreatorAnnotated(key: AnnotatedConstructor, calc: (AnnotatedConstructor) -> Boolean): Boolean = javaConstructorIsCreatorAnnotated.get(key)
53+
?: calc(key).let { javaConstructorIsCreatorAnnotated.putIfAbsent(key, it) ?: it }
54+
55+
fun javaMemberIsRequired(key: AnnotatedMember, calc: (AnnotatedMember) -> Boolean?): Boolean? = javaMemberIsRequired.get(key)?.value
56+
?: calc(key).let { javaMemberIsRequired.putIfAbsent(key, BooleanTriState.fromBoolean(it))?.value ?: it }
57+
58+
fun isKotlinGeneratedMethod(key: AnnotatedMethod, calc: (AnnotatedMethod) -> Boolean): Boolean = kotlinGeneratedMethod.get(key)
59+
?: calc(key).let { kotlinGeneratedMethod.putIfAbsent(key, it) ?: it }
4960
}

0 commit comments

Comments
 (0)