com.google.inject.TypeLiteral.fromSuperclassTypeParameter()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(13.5k)|赞(0)|评价(0)|浏览(83)

本文整理了Java中com.google.inject.TypeLiteral.fromSuperclassTypeParameter()方法的一些代码示例,展示了TypeLiteral.fromSuperclassTypeParameter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TypeLiteral.fromSuperclassTypeParameter()方法的具体详情如下:
包路径:com.google.inject.TypeLiteral
类名称:TypeLiteral
方法名:fromSuperclassTypeParameter

TypeLiteral.fromSuperclassTypeParameter介绍

[英]Gets type literal from super class's type parameter.
[中]从超类的类型参数中获取类型文字。

代码示例

代码示例来源:origin: com.google.inject/guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo}:
 *
 * <p>{@code new Key<Foo>() {}}.
 */
@SuppressWarnings("unchecked")
protected Key() {
 this.annotationStrategy = NullAnnotationStrategy.INSTANCE;
 this.typeLiteral =
   MoreTypes.canonicalizeForKey(
     (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
 this.hashCode = computeHashCode();
}

代码示例来源:origin: com.google.inject/guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(Bar.class) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Class<? extends Annotation> annotationType) {
 this.annotationStrategy = strategyFor(annotationType);
 this.typeLiteral =
   MoreTypes.canonicalizeForKey(
     (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
 this.hashCode = computeHashCode();
}

代码示例来源:origin: com.google.inject/guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(new Bar()) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Annotation annotation) {
 // no usages, not test-covered
 this.annotationStrategy = strategyFor(annotation);
 this.typeLiteral =
   MoreTypes.canonicalizeForKey(
     (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
 this.hashCode = computeHashCode();
}

代码示例来源:origin: com.google/inject

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo}:
 *
 * <p>{@code new Key<Foo>() {}}.
 */
@SuppressWarnings("unchecked")
protected Key() {
 this.annotationStrategy = NullAnnotationStrategy.INSTANCE;
 this.typeLiteral = (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass());
 this.hashCode = computeHashCode();
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.inject

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo}:
 *
 * <p>{@code new Key<Foo>() {}}.
 */
@SuppressWarnings("unchecked")
protected Key() {
 this.annotationStrategy = NullAnnotationStrategy.INSTANCE;
 this.typeLiteral = (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass());
 this.hashCode = computeHashCode();
}

代码示例来源:origin: Nextdoor/bender

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo}:
 *
 * <p>{@code new Key<Foo>() {}}.
 */
@SuppressWarnings("unchecked")
protected Key() {
 this.annotationStrategy = NullAnnotationStrategy.INSTANCE;
 this.typeLiteral = (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass());
 this.hashCode = computeHashCode();
}

代码示例来源:origin: com.google.code.guice/guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo}:
 *
 * <p>{@code new Key<Foo>() {}}.
 */
@SuppressWarnings("unchecked")
protected Key() {
 this.annotationStrategy = NULL_STRATEGY;
 this.typeLiteral
   = (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass());
 this.hashCode = computeHashCode();
}

代码示例来源:origin: org.sonatype.sisu/sisu-guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo}:
 *
 * <p>{@code new Key<Foo>() {}}.
 */
@SuppressWarnings("unchecked")
protected Key() {
 this.annotationStrategy = NullAnnotationStrategy.INSTANCE;
 this.typeLiteral =
   MoreTypes.canonicalizeForKey(
     (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
 this.hashCode = computeHashCode();
}

代码示例来源:origin: Nextdoor/bender

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with
 * {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(Bar.class) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Class<? extends Annotation> annotationType) {
 this.annotationStrategy = strategyFor(annotationType);
 this.typeLiteral = (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass());
 this.hashCode = computeHashCode();
}

代码示例来源:origin: Nextdoor/bender

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with
 * {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(new Bar()) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Annotation annotation) {
 // no usages, not test-covered
 this.annotationStrategy = strategyFor(annotation);
 this.typeLiteral = (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass());
 this.hashCode = computeHashCode();
}

代码示例来源:origin: com.google.code.guice/guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with
 * {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(Bar.class) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Class<? extends Annotation> annotationType) {
 this.annotationStrategy = strategyFor(annotationType);
 this.typeLiteral
   = (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass());
 this.hashCode = computeHashCode();
}

代码示例来源:origin: com.jwebmp.inject/guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo}:
 *
 * <p>{@code new Key<Foo>() {}}.
 */
@SuppressWarnings("unchecked")
protected Key() {
 this.annotationStrategy = NullAnnotationStrategy.INSTANCE;
 this.typeLiteral =
   MoreTypes.canonicalizeForKey(
     (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
 this.hashCode = computeHashCode();
}

代码示例来源:origin: com.google/inject

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with
 * {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(Bar.class) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Class<? extends Annotation> annotationType) {
 this.annotationStrategy = strategyFor(annotationType);
 this.typeLiteral = (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass());
 this.hashCode = computeHashCode();
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.inject

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with
 * {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(new Bar()) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Annotation annotation) {
 // no usages, not test-covered
 this.annotationStrategy = strategyFor(annotation);
 this.typeLiteral = (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass());
 this.hashCode = computeHashCode();
}

代码示例来源:origin: org.sonatype.sisu/sisu-guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(new Bar()) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Annotation annotation) {
 // no usages, not test-covered
 this.annotationStrategy = strategyFor(annotation);
 this.typeLiteral =
   MoreTypes.canonicalizeForKey(
     (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
 this.hashCode = computeHashCode();
}

代码示例来源:origin: org.sonatype.sisu/sisu-guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(Bar.class) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Class<? extends Annotation> annotationType) {
 this.annotationStrategy = strategyFor(annotationType);
 this.typeLiteral =
   MoreTypes.canonicalizeForKey(
     (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
 this.hashCode = computeHashCode();
}

代码示例来源:origin: com.jwebmp.inject/guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(new Bar()) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Annotation annotation) {
 // no usages, not test-covered
 this.annotationStrategy = strategyFor(annotation);
 this.typeLiteral =
   MoreTypes.canonicalizeForKey(
     (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
 this.hashCode = computeHashCode();
}

代码示例来源:origin: com.jwebmp.inject/guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(Bar.class) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Class<? extends Annotation> annotationType) {
 this.annotationStrategy = strategyFor(annotationType);
 this.typeLiteral =
   MoreTypes.canonicalizeForKey(
     (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
 this.hashCode = computeHashCode();
}

代码示例来源:origin: org.xbib/guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo}:
 *
 * <p>{@code new Key<Foo>() {}}.
 */
@SuppressWarnings("unchecked")
protected Key() {
  this.annotationStrategy = NullAnnotationStrategy.INSTANCE;
  this.typeLiteral = MoreTypes.canonicalizeForKey(
      (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
  this.hashCode = computeHashCode();
  this.toStringSupplier = createToStringSupplier();
}

代码示例来源:origin: org.xbib/guice

/**
 * Constructs a new key. Derives the type from this class's type parameter.
 *
 * <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.
 *
 * <p>Example usage for a binding of type {@code Foo} annotated with
 * {@code @Bar}:
 *
 * <p>{@code new Key<Foo>(Bar.class) {}}.
 */
@SuppressWarnings("unchecked")
protected Key(Class<? extends Annotation> annotationType) {
  this.annotationStrategy = strategyFor(annotationType);
  this.typeLiteral = MoreTypes.canonicalizeForKey(
      (TypeLiteral<T>) TypeLiteral.fromSuperclassTypeParameter(getClass()));
  this.hashCode = computeHashCode();
  this.toStringSupplier = createToStringSupplier();
}

相关文章