@@ -13,9 +13,9 @@ import kotlin.reflect.jvm.kotlinFunction
13
13
14
14
internal class ReflectionCache (reflectionCacheSize : Int ) {
15
15
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 )
19
19
20
20
companion object {
21
21
private val TRUE = True ()
@@ -40,10 +40,21 @@ internal class ReflectionCache(reflectionCacheSize: Int) {
40
40
private val kotlinGeneratedMethod = LRUMap <AnnotatedMethod , Boolean >(reflectionCacheSize, reflectionCacheSize)
41
41
42
42
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 }
49
60
}
0 commit comments