Beispiel #1
0
 /** Unsafe. Constructs a type literal manually. */
 @SuppressWarnings("unchecked")
 TypeLiteral(Type type) {
   this.type = MoreTypes.canonicalize(type);
   this.rawType = (Class<? super T>) MoreTypes.getRawType(this.type);
   this.hashCode = this.type.hashCode();
 }
Beispiel #2
0
 /**
  * Constructs a new type literal. Derives represented class from type parameter.
  *
  * <p>
  *
  * <p>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.
  */
 @SuppressWarnings("unchecked")
 protected TypeLiteral() {
   this.type = getSuperclassTypeParameter(getClass());
   this.rawType = (Class<? super T>) MoreTypes.getRawType(type);
   this.hashCode = type.hashCode();
 }