Injector. A Guice key consists of an injection type and an optional annotation.
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 corresponding wrapper types (Integer, Character, etc.). Primitive types will be replaced with their wrapper types when keys are created.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| pack-priv static interface | |
| pack-priv static class | |
| pack-priv static enum |
| Modifier and Type | Field and Description |
|---|---|
| private final Key. | |
| private final int | |
| private String | |
| private final TypeLiteral |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected | |
| protected | |
| private | |
| private | Key(TypeLiteral<T> typeLiteral, Key.
Constructs a key from a manually specified type. |
| Modifier and Type | Method and Description |
|---|---|
| private int | |
| private static void | |
| private static void | |
| public final boolean | equals(Object
the reference object with which to compare. o)Overrides java. |
| pack-priv static <T> Key | get(Class<T> type, Key.
Gets a key for an injection type and an annotation strategy. |
| public static <T> Key | |
| public static <T> Key | get(Class<T> type, Class<? extends Annotation> annotationType)
Gets a key for an injection type and an annotation type. |
| public static <T> Key | |
| public static Key | |
| public static Key | get(Type type, Class<? extends Annotation> annotationType)
Gets a key for an injection type and an annotation type. |
| public static Key | |
| public static <T> Key | |
| public static <T> Key | get(TypeLiteral<T> typeLiteral, Class<? extends Annotation> annotationType)
Gets a key for an injection type and an annotation type. |
| public static <T> Key | get(TypeLiteral<T> typeLiteral, Annotation annotation)
Gets a key for an injection type and an annotation. |
| public final Annotation | |
| pack-priv String | |
| public final Class | |
| pack-priv Class | |
| public final TypeLiteral | |
| pack-priv boolean | |
| public boolean | |
| public final int | |
| public <U> Key | |
| public Key | |
| public <U> Key | ofType(TypeLiteral<U> type)
Returns a new key of the specified type with the same annotation as this key. |
| pack-priv Key | |
| pack-priv static Key. | |
| pack-priv static Key. | |
| public final String | |
| public Key | withAnnotation(Class<? extends Annotation> annotationType)
Returns a new key of the same type with the specified annotation. |
| public Key | withAnnotation(Annotation annotation)
Returns a new key of the same type with the specified annotation. |
| public Key | withoutAttributes()
Returns this key without annotation attributes, i.e. with only the annotation type. |
| annotationStrategy | back to summary |
|---|---|
| private final Key. | |
| hashCode | back to summary |
|---|---|
| private final int hashCode | |
| toString | back to summary |
|---|---|
| private String toString | |
| typeLiteral | back to summary |
|---|---|
| private final TypeLiteral<T> typeLiteral | |
| Key | back to summary |
|---|---|
| protected Key(Class<? extends Annotation> annotationType) 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
| |
| Key | back to summary |
|---|---|
| protected Key(Annotation annotation) 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
| |
| Key | back to summary |
|---|---|
| protected Key() 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
| |
| Key | back to summary |
|---|---|
| private Key(Type type, Key. Unsafe. Constructs a key from a manually specified type.
| |
| Key | back to summary |
|---|---|
| private Key(TypeLiteral<T> typeLiteral, Key. Constructs a key from a manually specified type. | |
| computeHashCode | back to summary |
|---|---|
| private int computeHashCode() Computes the hash code for this key. | |
| ensureIsBindingAnnotation | back to summary |
|---|---|
| private static void ensureIsBindingAnnotation(Class<? extends Annotation> annotationType) | |
| ensureRetainedAtRuntime | back to summary |
|---|---|
| private static void ensureRetainedAtRuntime(Class<? extends Annotation> annotationType) | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| get | back to summary |
|---|---|
| pack-priv static <T> Key Gets a key for an injection type and an annotation strategy. | |
| get | back to summary |
|---|---|
| public static <T> Key Gets a key for an injection type. | |
| get | back to summary |
|---|---|
| public static <T> Key Gets a key for an injection type and an annotation type. | |
| get | back to summary |
|---|---|
| public static <T> Key Gets a key for an injection type and an annotation. | |
| get | back to summary |
|---|---|
| public static Key Gets a key for an injection type. | |
| get | back to summary |
|---|---|
| public static Key Gets a key for an injection type and an annotation type. | |
| get | back to summary |
|---|---|
| public static Key Gets a key for an injection type and an annotation. | |
| get | back to summary |
|---|---|
| public static <T> Key Gets a key for an injection type. | |
| get | back to summary |
|---|---|
| public static <T> Key Gets a key for an injection type and an annotation type. | |
| get | back to summary |
|---|---|
| public static <T> Key Gets a key for an injection type and an annotation. | |
| getAnnotation | back to summary |
|---|---|
| public final Annotation getAnnotation() Gets the annotation instance if available. Will be Warning this can return null even if this key is annotated. To check whether a
| |
| getAnnotationName | back to summary |
|---|---|
| pack-priv String getAnnotationName() | |
| getAnnotationType | back to summary |
|---|---|
| public final Class Gets the annotation type. Will be | |
| getRawType | back to summary |
|---|---|
| pack-priv Class | |
| getTypeLiteral | back to summary |
|---|---|
| public final TypeLiteral Gets the key type. | |
| hasAnnotationType | back to summary |
|---|---|
| pack-priv boolean hasAnnotationType() | |
| hasAttributes | back to summary |
|---|---|
| public boolean hasAttributes() Returns true if this key has annotation attributes.
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| ofType | back to summary |
|---|---|
| public <U> Key Returns a new key of the specified type with the same annotation as this key.
| |
| ofType | back to summary |
|---|---|
| public Key Returns a new key of the specified type with the same annotation as this key.
| |
| ofType | back to summary |
|---|---|
| public <U> Key Returns a new key of the specified type with the same annotation as this key.
| |
| providerKey | back to summary |
|---|---|
| pack-priv Key Gets the key of this key's provider. | |
| strategyFor | back to summary |
|---|---|
| pack-priv static Key. Gets the strategy for an annotation. | |
| strategyFor | back to summary |
|---|---|
| pack-priv static Key. Gets the strategy for an annotation type. | |
| toString | back to summary |
|---|---|
| public final String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| withAnnotation | back to summary |
|---|---|
| public Key Returns a new key of the same type with the specified annotation. This is equivalent to
| |
| withAnnotation | back to summary |
|---|---|
| public Key Returns a new key of the same type with the specified annotation. This is equivalent to
| |
| withoutAttributes | back to summary |
|---|---|
| public Key Returns this key without annotation attributes, i.e. with only the annotation type.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Annotation |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. o)Overrides java. |
| public Annotation | |
| public Class | |
| public boolean | |
| public int | |
| public String | |
| public Key. |
| annotation | back to summary |
|---|---|
| pack-priv final Annotation annotation | |
| AnnotationInstanceStrategy | back to summary |
|---|---|
| pack-priv AnnotationInstanceStrategy(Annotation annotation) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getAnnotation | back to summary |
|---|---|
| public Annotation getAnnotation() Implements com.
| |
| getAnnotationType | back to summary |
|---|---|
| public Class Implements com.
| |
| hasAttributes | back to summary |
|---|---|
| public boolean hasAttributes() Implements com.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| withoutAttributes | back to summary |
|---|---|
| public Key. Implements com.
| |
| Modifier and Type | Method and Description |
|---|---|
| public Annotation | |
| public Class | |
| public boolean | |
| public Key. |
| getAnnotation | back to summary |
|---|---|
| public Annotation getAnnotation() | |
| getAnnotationType | back to summary |
|---|---|
| public Class | |
| hasAttributes | back to summary |
|---|---|
| public boolean hasAttributes() | |
| withoutAttributes | back to summary |
|---|---|
| public Key. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Annotation | |
| pack-priv final Class |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. o)Overrides java. |
| public Annotation | |
| public Class | |
| public boolean | |
| public int | |
| public String | |
| public Key. |
| annotation | back to summary |
|---|---|
| pack-priv final Annotation annotation | |
| annotationType | back to summary |
|---|---|
| pack-priv final Class<? extends Annotation> annotationType | |
| AnnotationTypeStrategy | back to summary |
|---|---|
| pack-priv AnnotationTypeStrategy(Class<? extends Annotation> annotationType, Annotation annotation) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getAnnotation | back to summary |
|---|---|
| public Annotation getAnnotation() Implements com.
| |
| getAnnotationType | back to summary |
|---|---|
| public Class Implements com.
| |
| hasAttributes | back to summary |
|---|---|
| public boolean hasAttributes() Implements com.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| withoutAttributes | back to summary |
|---|---|
| public Key. Implements com.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final Key. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Annotation | |
| public Class | |
| public boolean | |
| public String | toString()
Overrides java. |
| public static Key. | |
| public static Key. | |
| public Key. |
| INSTANCE | back to summary |
|---|---|
| public static final Key. | |
| NullAnnotationStrategy | back to summary |
|---|---|
| private NullAnnotationStrategy() | |
| getAnnotation | back to summary |
|---|---|
| public Annotation getAnnotation() Implements com.
| |
| getAnnotationType | back to summary |
|---|---|
| public Class Implements com.
| |
| hasAttributes | back to summary |
|---|---|
| public boolean hasAttributes() Implements com.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists. | |
| valueOf | back to summary |
|---|---|
| public static Key. | |
| values | back to summary |
|---|---|
| public static Key. | |
| withoutAttributes | back to summary |
|---|---|
| public Key. Implements com.
| |