|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.inject.Key<T>
public abstract class Key<T>
Binding key consisting of a type and a name. Matches the type and
name (Inject.value()
) at a point of injection.
For example, new Key<List<String>>("cities") {} will match:
@Inject("cities") public void setList(List<String> cities) { ... }
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_NAME
Default binding name. |
Constructor Summary | |
---|---|
protected |
Key()
Convenience method. |
protected |
Key(java.lang.String name)
Constructs a new key. |
Method Summary | ||
---|---|---|
boolean |
equals(java.lang.Object o)
|
|
static
|
get(java.lang.Class<T> type)
Gets a key for a Class . |
|
static
|
get(java.lang.Class<T> type,
java.lang.String name)
Gets a key for a Class and a name. |
|
static Key<?> |
get(java.lang.reflect.Type type)
Gets a key for a type. |
|
static
|
get(TypeLiteral<T> typeLiteral)
Gets a key for a type. |
|
static
|
get(TypeLiteral<T> typeLiteral,
java.lang.String name)
Gets key for a type and a name. |
|
static Key<?> |
get(java.lang.reflect.Type type,
java.lang.String name)
Gets a key for a type and a name. |
|
java.lang.String |
getName()
Gets the binding name. |
|
TypeLiteral<T> |
getType()
Gets the key type. |
|
boolean |
hasDefaultName()
Returns true if this key has the default name. |
|
int |
hashCode()
|
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_NAME
Constructor Detail |
---|
protected Key(java.lang.String name)
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
named "bar":
new Key<Foo>("bar") {}
.
protected Key()
Key(String)
with
DEFAULT_NAME
.
Method Detail |
---|
public boolean hasDefaultName()
true
if this key has the default name.
public TypeLiteral<T> getType()
public java.lang.String getName()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static <T> Key<T> get(java.lang.Class<T> type)
Class
. Defaults name to DEFAULT_NAME
.
public static <T> Key<T> get(java.lang.Class<T> type, java.lang.String name)
Class
and a name.
public static Key<?> get(java.lang.reflect.Type type)
DEFAULT_NAME
.
public static Key<?> get(java.lang.reflect.Type type, java.lang.String name)
public static <T> Key<T> get(TypeLiteral<T> typeLiteral)
DEFAULT_NAME
.
public static <T> Key<T> get(TypeLiteral<T> typeLiteral, java.lang.String name)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |