Class/Object

play.api.inject

BindingKey

Related Docs: object BindingKey | package inject

Permalink

final case class BindingKey[T](clazz: Class[T], qualifier: Option[QualifierAnnotation]) extends Product with Serializable

A binding key.

A binding key consists of a class and zero or more JSR-330 qualifiers.

clazz

The class to bind.

qualifier

An optional qualifier.

Source
Binding.scala
See also

The Module class for information on how to provide bindings.

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BindingKey
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new BindingKey(clazz: Class[T])

    Permalink
  2. new BindingKey(clazz: Class[T], qualifier: Option[QualifierAnnotation])

    Permalink

    clazz

    The class to bind.

    qualifier

    An optional qualifier.

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. val clazz: Class[T]

    Permalink

    The class to bind.

  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  12. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  13. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. def qualifiedWith(name: String): BindingKey[T]

    Permalink

    Qualify this binding key with the given name.

    Qualify this binding key with the given name.

    For example, you may have both a cached implementation, and a direct implementation of a service. To differentiate between them, you may decide to name the cached one:

    bind[Foo].qualifiedWith("cached").to[FooCached],
    bind[Foo].to[FooImpl]
    
    ...
    
    class MyController @Inject() (@Named("cached") foo: Foo) {
      ...
    }

    In the above example, the controller will get the cached Foo service.

  15. def qualifiedWith[A <: Annotation](implicit arg0: ClassTag[A]): BindingKey[T]

    Permalink

    Qualify this binding key with the given annotation.

    Qualify this binding key with the given annotation.

    For example, you may have both a cached implementation, and a direct implementation of a service. To differentiate between them, you may define a Cached annotation:

    import scala.annotation._
    
    @target.param
    class Cached extends StaticAnnotation
    
    ...
    
    bind[Foo].qualifiedWith[Cached].to[FooCached],
    bind[Foo].to[FooImpl]
    
    ...
    
    class MyController @Inject() (@Cached foo: Foo) {
      ...
    }

    In the above example, the controller will get the cached Foo service.

  16. def qualifiedWith[A <: Annotation](annotation: Class[A]): BindingKey[T]

    Permalink

    Qualify this binding key with the given annotation.

    Qualify this binding key with the given annotation.

    For example, you may have both a cached implementation, and a direct implementation of a service. To differentiate between them, you may define a Cached annotation:

    import scala.annotation._
    
    @target.param
    class Cached extends StaticAnnotation
    
    ...
    
    bind[Foo].qualifiedWith(classOf[Cached]).to[FooCached],
    bind[Foo].to[FooImpl]
    
    ...
    
    class MyController @Inject() (@Cached foo: Foo) {
      ...
    }

    In the above example, the controller will get the cached Foo service.

  17. def qualifiedWith[A <: Annotation](instance: A): BindingKey[T]

    Permalink

    Qualify this binding key with the given instance of an annotation.

    Qualify this binding key with the given instance of an annotation.

    This can be used to specify bindings with annotations that have particular values.

  18. val qualifier: Option[QualifierAnnotation]

    Permalink

    An optional qualifier.

  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  20. def to(key: BindingKey[_ <: T]): Binding[T]

    Permalink

    Bind this binding key to another binding key.

  21. def to[A <: T](instance: ⇒ A): Binding[T]

    Permalink

    Bind this binding key to the given instance.

  22. def to(provider: Provider[_ <: T]): Binding[T]

    Permalink

    Bind this binding key to the given provider instance.

    Bind this binding key to the given provider instance.

    This provider instance will be invoked to obtain the implementation for the key.

  23. def to[C <: T](implicit arg0: ClassTag[C]): Binding[T]

    Permalink

    Bind this binding key to the given implementation class.

    Bind this binding key to the given implementation class.

    This class will be instantiated and injected by the injection framework.

  24. def to(implementation: Class[_ <: T]): Binding[T]

    Permalink

    Bind this binding key to the given implementation class.

    Bind this binding key to the given implementation class.

    This class will be instantiated and injected by the injection framework.

  25. def toInstance(instance: T): Binding[T]

    Permalink

    Bind this binding key to the given instance.

  26. def toProvider[P <: Provider[_ <: T]](implicit arg0: ClassTag[P]): Binding[T]

    Permalink

    Bind this binding key to the given provider class.

    Bind this binding key to the given provider class.

    The dependency injection framework will instantiate and inject this provider, and then invoke its get method whenever an instance of the class is needed.

  27. def toProvider[P <: Provider[_ <: T]](provider: Class[P]): Binding[T]

    Permalink

    Bind this binding key to the given provider class.

    Bind this binding key to the given provider class.

    The dependency injection framework will instantiate and inject this provider, and then invoke its get method whenever an instance of the class is needed.

  28. def toSelf: Binding[T]

    Permalink

    Bind this binding key to itself.

  29. def toString(): String

    Permalink
    Definition Classes
    BindingKey → AnyRef → Any
  30. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped