public final class BindingKey<T>
extends java.lang.Object
Module
class for information on how to provide bindings.Constructor and Description |
---|
BindingKey(play.api.inject.BindingKey<T> underlying) |
BindingKey(java.lang.Class<T> clazz) |
BindingKey(java.lang.Class<T> clazz,
java.util.Optional<QualifierAnnotation> qualifier)
A binding key.
|
Modifier and Type | Method and Description |
---|---|
play.api.inject.BindingKey<T> |
asScala() |
java.lang.Class<T> |
getClazz() |
java.util.Optional<QualifierAnnotation> |
getQualifier() |
<A extends java.lang.annotation.Annotation> |
qualifiedWith(A instance)
Qualify this binding key with the given instance of an annotation.
|
<A extends java.lang.annotation.Annotation> |
qualifiedWith(java.lang.Class<A> annotation)
Qualify this binding key with the given annotation.
|
BindingKey<T> |
qualifiedWith(java.lang.String name)
Qualify this binding key with the given name.
|
Binding<T> |
to(BindingKey<? extends T> key)
Bind this binding key to another binding key.
|
Binding<T> |
to(java.lang.Class<? extends T> implementation)
Bind this binding key to the given implementation class.
|
Binding<T> |
to(javax.inject.Provider<? extends T> provider)
Bind this binding key to the given provider instance.
|
<A extends T> |
to(java.util.function.Supplier<A> instance)
Bind this binding key to the given instance.
|
Binding<T> |
toInstance(T instance)
Bind this binding key to the given instance.
|
<P extends javax.inject.Provider<? extends T>> |
toProvider(java.lang.Class<P> provider)
Bind this binding key to the given provider class.
|
Binding<T> |
toSelf()
Bind this binding key to itself.
|
java.lang.String |
toString() |
public BindingKey(java.lang.Class<T> clazz, java.util.Optional<QualifierAnnotation> qualifier)
Module
class for information on how to provide bindings.clazz
- The class to bind.qualifier
- An optional qualifier.public BindingKey(play.api.inject.BindingKey<T> underlying)
public BindingKey(java.lang.Class<T> clazz)
public java.lang.Class<T> getClazz()
public java.util.Optional<QualifierAnnotation> getQualifier()
public <A extends java.lang.annotation.Annotation> BindingKey<T> qualifiedWith(A instance)
public <A extends java.lang.annotation.Annotation> BindingKey<T> qualifiedWith(java.lang.Class<A> annotation)
bindClass(Foo.class).qualifiedWith(Cached.class).to(FooCached.class),
bindClass(Foo.class).to(FooImpl.class)
...
class MyController {
{@literal @}Inject
MyController({@literal @}Cached Foo foo) {
...
}
...
}
In the above example, the controller will get the cached Foo
service.public BindingKey<T> qualifiedWith(java.lang.String name)
bindClass(Foo.class).qualifiedWith("cached").to(FooCached.class),
bindClass(Foo.class).to(FooImpl.class)
...
class MyController {
{@literal @}Inject
MyController({@literal @}Named("cached") Foo foo) {
...
}
...
}
In the above example, the controller will get the cached `Foo` service.public Binding<T> to(java.lang.Class<? extends T> implementation)
public Binding<T> to(javax.inject.Provider<? extends T> provider)
public <A extends T> Binding<T> to(java.util.function.Supplier<A> instance)
public Binding<T> to(BindingKey<? extends T> key)
public <P extends javax.inject.Provider<? extends T>> Binding<T> toProvider(java.lang.Class<P> provider)
public java.lang.String toString()
toString
in class java.lang.Object
public play.api.inject.BindingKey<T> asScala()