MCPcopy Index your code
hub / github.com/google/guice / Key

Method Key

core/src/com/google/inject/Key.java:73–80  ·  view source on GitHub ↗

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 {@code Foo

(Class<? extends Annotation> annotationType)

Source from the content-addressed store, hash-verified

71 * <p>{@code new Key<Foo>(Bar.class) {}}.
72 */
73 @SuppressWarnings("unchecked")
74 protected Key(Class<? extends Annotation> annotationType) {
75 this.annotationStrategy = strategyFor(annotationType);
76 this.typeLiteral =
77 MoreTypes.canonicalizeForKey(
78 (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
79 this.hashCode = computeHashCode();
80 }
81
82 /**
83 * Constructs a new key. Derives the type from this class's type parameter.

Callers

nothing calls this directly

Calls 5

strategyForMethod · 0.95
canonicalizeForKeyMethod · 0.95
computeHashCodeMethod · 0.95
getMethod · 0.95

Tested by

no test coverage detected