java.lang.Object | |
↳ | com.google.inject.Key<T> |
Binding key consisting of an injection type and an optional annotation. Matches the type and annotation at a point of injection.
For example, Key.get(Service.class, Transactional.class)
will
match:
@Inject public void setService(@Transactional Service service) { ... }
Key
supports generic types via subclassing just like TypeLiteral
.
Keys do not differentiate between primitive types (int, char, etc.) and their correpsonding wrapper types (Integer, Character, etc.). Primitive types will be replaced with their wrapper types when keys are created.
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new key.
| |||||||||||
Constructs a new key.
| |||||||||||
Constructs a new key.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets a key for an injection type.
| |||||||||||
Gets a key for an injection type and an annotation type.
| |||||||||||
Gets a key for an injection type and an annotation.
| |||||||||||
Gets a key for an injection type.
| |||||||||||
Gets a key for an injection type and an annotation type.
| |||||||||||
Gets a key for an injection type and an annotation.
| |||||||||||
Gets a key for an injection type.
| |||||||||||
Gets a key for an injection type and an annotation type.
| |||||||||||
Gets a key for an injection type and an annotation.
| |||||||||||
Gets the annotation.
| |||||||||||
Gets the annotation type.
| |||||||||||
Gets the key type.
| |||||||||||
Returns true if this key has annotation attributes.
| |||||||||||
Returns a new key of the specified type with the same annotation as this
key.
| |||||||||||
Returns a new key of the specified type with the same annotation as this
key.
| |||||||||||
Returns a new key of the specified type with the same annotation as this
key.
| |||||||||||
Returns this key without annotation attributes, i.e.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Constructs a new key. Derives the type from this class's type parameter.
Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.
Example usage for a binding of type Foo
:
new Key<Foo>() {
}.
Constructs a new key. Derives the type from this class's type parameter.
Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.
Example usage for a binding of type Foo
annotated with
@Bar
:
new Key<Foo>(Bar.class) {
}.
Constructs a new key. Derives the type from this class's type parameter.
Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.
Example usage for a binding of type Foo
annotated with
@Bar
:
new Key<Foo>(new Bar()) {
}.
Gets a key for an injection type.
Gets a key for an injection type and an annotation type.
Gets a key for an injection type and an annotation.
Gets a key for an injection type.
Gets a key for an injection type and an annotation type.
Gets a key for an injection type and an annotation.
Gets a key for an injection type and an annotation type.
Gets a key for an injection type and an annotation.
Gets the annotation type.
Returns true if this key has annotation attributes.
Returns a new key of the specified type with the same annotation as this key.
Returns a new key of the specified type with the same annotation as this key.
Returns a new key of the specified type with the same annotation as this key.
Returns this key without annotation attributes, i.e. with only the annotation type.