Skip to content

Commit

Permalink
auto fix deprecated usage
Browse files Browse the repository at this point in the history
  • Loading branch information
czp3009 committed Dec 12, 2023
1 parent da11cfb commit dbc17de
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/main/kotlin/com/hiczp/caeruleum/Caeruleum.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ import kotlin.reflect.full.allSuperclasses
* @param useCache save resolved ServiceFunction and reuse it, default is true
*/
class Caeruleum(useCache: Boolean = true) {
private val resolveServiceFunction: (method: Method, parse: (method: Method) -> ServiceFunction) -> ServiceFunction

init {
resolveServiceFunction = if (useCache) {
private val resolveServiceFunction: (method: Method, parse: (method: Method) -> ServiceFunction) -> ServiceFunction =
if (useCache) {
val cachedServiceFunctions = ConcurrentHashMap<Method, ServiceFunction>()
({ method, parse -> cachedServiceFunctions.computeIfAbsent(method) { parse(it) } })
} else {
{ method, parse -> parse(method) }
}
}

/**
* Create ServiceInterface implementation
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/hiczp/caeruleum/ServiceFunction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED

internal sealed interface ServiceFunction : InvocationHandler

internal object DelegationServiceFunction : ServiceFunction {
internal data object DelegationServiceFunction : ServiceFunction {
override fun invoke(proxy: Any, method: Method, args: Array<out Any?>?): Any? = method(proxy, *args.orEmpty())
}

Expand Down

0 comments on commit dbc17de

Please sign in to comment.