blob: 83de99112b8b74fce191d8eec388aecae60ffba7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package org.jetbrains.dokka.base.resolvers.external
import org.jetbrains.dokka.links.DRI
import java.util.concurrent.ConcurrentHashMap
interface ExternalLocationProvider {
val param: String
fun DRI.toLocation(): String
}
interface ExternalLocationProviderFactory {
fun getExternalLocationProvider(param: String): ExternalLocationProvider?
}
class ExternalLocationProviderFactoryWithCache(val ext: ExternalLocationProviderFactory) : ExternalLocationProviderFactory {
private val locationProviders = ConcurrentHashMap<String, CacheWrapper>()
override fun getExternalLocationProvider(param: String): ExternalLocationProvider? =
locationProviders.getOrPut(param) { CacheWrapper(ext.getExternalLocationProvider(param)) }.provider
}
private class CacheWrapper(val provider: ExternalLocationProvider?)
|