All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.org.kodein.di.SetBindings.kt Maven / Gradle / Ivy

There is a newer version: 7.22.0
Show newest version
@file:Suppress("unused", "UNCHECKED_CAST")

package org.kodein.di

import org.kodein.di.bindings.*
import org.kodein.type.TypeToken
import org.kodein.type.erasedComp
import org.kodein.type.generic

/**
 * Creates a set: multiple bindings can be added in this set.
 *
 * T generics will be erased!
 *
 * @param T The created type.
 * @return A set binding ready to be bound.
 */
@Suppress("RemoveExplicitTypeArguments")
@Deprecated(
    message = "'bind() from ...' has been deprecated",
    replaceWith = ReplaceWith("bindSet()"),
    level = DeprecationLevel.ERROR
)
public inline fun  DI.Builder.setBinding(): SetBinding = SetBinding(TypeToken.Any, generic(), erasedComp(Set::class, generic()) as TypeToken>)

/**
 * Creates a set: multiple bindings can be added in this set.
 *
 * A & T generics will be erased!
 *
 * @param A The argument type.
 * @param T The created type.
 * @return A set binding ready to be bound.
 */
@Suppress("RemoveExplicitTypeArguments")
@Deprecated(
    message = "'bind() from ...' has been deprecated",
    replaceWith = ReplaceWith("bindArgSet()"),
    level = DeprecationLevel.ERROR
)
public inline fun  DI.Builder.argSetBinding(): ArgSetBinding = ArgSetBinding(TypeToken.Any, generic(), generic(), erasedComp(Set::class, generic()) as TypeToken>)

/**
 * Creates a set: multiple bindings can be added in this set.
 *
 * T generics will be erased!
 *
 * @param T The created type.
 * @return A set binding ready to be bound.
 */
@Suppress("RemoveExplicitTypeArguments")
public inline fun  DI.Builder.bindSet(tag: Any? = null, overrides: Boolean? = null): Unit = Bind(tag = tag, overrides = overrides, binding = SetBinding(TypeToken.Any, generic(), erasedComp(Set::class, generic()) as TypeToken>))

/**
 * Creates a set: multiple bindings can be added in this set.
 *
 * T generics will be erased!
 *
 * @param A The argument type.
 * @param T The created type.
 * @return A set binding ready to be bound.
 */
@Suppress("RemoveExplicitTypeArguments")
public inline fun  DI.Builder.bindArgSet(tag: Any? = null, overrides: Boolean? = null): Unit = Bind(tag = tag, overrides = overrides, binding = ArgSetBinding(TypeToken.Any, generic(), generic(), erasedComp(Set::class, generic()) as TypeToken>))

/**
 * Defines that the binding will be saved in a set binding.
 *
 * T generics will be erased!
 *
 * @param T The type of the binding.
 */
public inline fun  DI.Builder.TypeBinder.inSet(): TypeBinderInSet> = InSet(erasedComp(Set::class, generic()) as TypeToken>)

/**
 * Defines that the binding will be saved in a set binding.
 *
 * T generics will be erased!
 *
 * @param T The type of the binding.
 */
public inline fun  DI.Builder.inSet(tag: Any? = null, overrides: Boolean? = null, creator: () -> DIBinding<*, *, T>): Unit = BindSet(tag = tag, overrides = overrides, creator())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy