ResolveByName

annotation class ResolveByName(val name: String = USE_PARAMETER_NAME)

Mark parameter as injected by name rather than type

Unless another name is provided, the paramater name is used for resolution.

To provide a named value of type T to the dependency resolution, use a Tuple<String, T>. (Which you can make with the construct "name" to value).

Example:

class FrobnicatorClient(
@ResolveByName private val frobnicatorUrl: String
)

val context = resolveDependencies(
"frobnicatorUrl" to System.getenv("FROB_URL"),
FrobnicatorClient::class
)

context.get<String>("frobnicatorUrl")

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard