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)
| 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. |
nothing calls this directly
no test coverage detected