Package-level declarations

Types

Link copied to clipboard
class ArgSetBinding<C : Any, A, T : Any>(val contextType: TypeToken<in C>, val argType: TypeToken<in A>, _elementType: TypeToken<out T>, val createdType: TypeToken<out Set<T>>) : BaseMultiBinding<C, A, T>

Binding that holds multiple factory bindings (e.g. with argument) in a set.

Link copied to clipboard
abstract class BaseMultiBinding<C : Any, A, T : Any> : DIBinding<C, A, Set<T>>

Base class for binding set.

Link copied to clipboard
interface Binding<C : Any, A, T : Any>

Base class that knows how to get an instance.

Link copied to clipboard
interface BindingDI<out C : Any> : DirectDI, WithContext<C>

Direct DI interface to be passed to factory methods that hold references.

Link copied to clipboard
interface ContextTranslator<in C : Any, S : Any>
Link copied to clipboard
interface DIBinding<C : Any, A, T : Any> : Binding<C, A, T>

Binding that is registered inside a DI object.

Link copied to clipboard
class EagerSingleton<T : Any>(builder: DIContainer.Builder, val createdType: TypeToken<out T>, val creator: NoArgBindingDI<Any>.() -> T) : NoArgDIBinding<Any, T>

Concrete eager singleton: will create an instance as soon as di is ready (all bindings are set) and will always return this instance.

Link copied to clipboard
Link copied to clipboard
interface ExternalSource

An external source can provide to an answer to a retrieval that do not correspond to any binding that is registered in DI.

Link copied to clipboard
class Factory<C : Any, A, T : Any>(val contextType: TypeToken<in C>, val argType: TypeToken<in A>, val createdType: TypeToken<out T>, creator: BindingDI<C>.(A) -> T) : DIBinding<C, A, T>

Concrete factory: each time an instance is needed, the function creator function will be called.

Link copied to clipboard
class InstanceBinding<T : Any>(val createdType: TypeToken<out T>, val instance: T) : NoArgDIBinding<Any, T>

Concrete instance provider: will always return the given instance.

Link copied to clipboard
class Multiton<C : Any, A, T : Any>(val scope: Scope<C>, val contextType: TypeToken<in C>, explicitContext: Boolean, val argType: TypeToken<in A>, val createdType: TypeToken<out T>, refMaker: RefMaker? = null, val sync: Boolean = true, creator: BindingDI<C>.(A) -> T) : DIBinding<C, A, T>

Concrete multiton: will create one and only one instance for each argument. Will create the instance on first time a given argument is used and will subsequently always return the same instance for the same argument.

Link copied to clipboard
interface NoArgBindingDI<out C : Any> : DirectDI, WithContext<C>

Direct DI interface to be passed to provider methods that hold references.

Link copied to clipboard
interface NoArgDIBinding<C : Any, T : Any> : DIBinding<C, Unit, T>

DIBinding specialization that has no argument.

Link copied to clipboard
class NoScope : Scope<Any?>

Default Scope: will always return the same registry, no matter the context.

Link copied to clipboard
class Provider<C : Any, T : Any>(val contextType: TypeToken<in C>, val createdType: TypeToken<out T>, val creator: NoArgBindingDI<C>.() -> T) : NoArgDIBinding<C, T>

Concrete provider: each time an instance is needed, the function creator function will be called.

Link copied to clipboard
data class Reference<out T : Any>(val current: T, val next: () -> T?)

A reference gives a data and a function to later check the validity and retrieve that data.

Link copied to clipboard
interface RefMaker

A Function that creates a reference.

Link copied to clipboard
interface Scope<in C>

A scope is an object that can return (or create) a ScopeRegistry according to a context.

Link copied to clipboard
interface ScopeCloseable
Link copied to clipboard

A registry is responsible managing references inside a scope.

Link copied to clipboard
class SetBinding<C : Any, T : Any>(val contextType: TypeToken<in C>, _elementType: TypeToken<out T>, val createdType: TypeToken<out Set<T>>) : BaseMultiBinding<C, Unit, T> , NoArgDIBinding<C, Set<T>>

Binding that holds multiple factory bindings (e.g. with argument) in a set.

Link copied to clipboard
class SimpleAutoContextTranslator<S : Any>(val scopeType: TypeToken<in S>, t: DirectDI.() -> S) : ContextTranslator<Any, S>
Link copied to clipboard
class SimpleContextTranslator<in C : Any, S : Any>(val contextType: TypeToken<in C>, val scopeType: TypeToken<in S>, t: DirectDI.(ctx: C) -> S?) : ContextTranslator<C, S>
Link copied to clipboard

ScopeRegistry that is specialized to hold only one item.

Link copied to clipboard
class Singleton<C : Any, T : Any>(val scope: Scope<C>, val contextType: TypeToken<in C>, explicitContext: Boolean, val createdType: TypeToken<out T>, refMaker: RefMaker? = null, val sync: Boolean = true, val creator: NoArgBindingDI<C>.() -> T) : NoArgDIBinding<C, T>

Singleton Binding: will create an instance on first request and will subsequently always return the same instance.

Link copied to clipboard

A reference that acts as a Singleton: calls a creator function the first time, and then always return the same instance.

Link copied to clipboard

Standard ScopeRegistry implementation.

Link copied to clipboard
abstract class SubScope<C, PC>(parentScope: Scope<PC>) : Scope<C>
Link copied to clipboard
class SubTypes<C : Any, A, T : Any>(val contextType: TypeToken<in C>, val argType: TypeToken<in A>, val createdType: TypeToken<out T>, val block: (TypeToken<out T>) -> <Error class: unknown class><in C, in A, out T>)

Binding that holds multiple bindings for subtypes of T.

Link copied to clipboard
class TypeBinderInSet<in T : Any, S : Any>

Second part of the bind<Type>().inSet() with binding syntax.

Link copied to clipboard

Second part of the bind<Type>().inSet() with binding syntax.

Link copied to clipboard
open class UnboundedScope(val registry: ScopeRegistry = StandardScopeRegistry()) : Scope<Any?> , ScopeCloseable

Scope that is not bound to a context (always lives).

Link copied to clipboard
open class WeakContextScope<in C>(val newRepo: () -> <Error class: unknown class> = { StandardScopeRegistry() })

Scope that map ScopeRegistry associated to weak contexts.

Link copied to clipboard
interface WithContext<out C : Any>

Indicates that the context of a retrieval is accessible.

Functions

Link copied to clipboard
fun externalFactory(f: (Any?) -> Any): (Any?) -> Any

Simple function that types a lambda as a factory function that can be used as the return in the implementation of ExternalSource.getFactory.

Link copied to clipboard
fun <T : Any> DI.Builder.TypeBinder<T>.InSet(setTypeToken: TypeToken<Set<T>>): TypeBinderInSet<T, Set<T>>

Allows to bind in an existing set binding (rather than directly as a new binding).

Link copied to clipboard
fun <T : Any> <Error class: unknown class><T>.subTypes(): TypeBinderSubTypes<T>

Allows to bind in an existing set binding (rather than directly as a new binding).

Link copied to clipboard
fun <C : Any, S : Any> ContextTranslator<C, S>.toKContext(di: DirectDI, ctx: C): DIContext<S>?