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

x33g5p2x  于2022-01-23 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(97)

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

Key.strategyFor介绍

[英]Gets the strategy for an annotation type.
[中]

代码示例

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

/** Gets a key for an injection type and an annotation type. */
public static <T> Key<T> get(
  TypeLiteral<T> typeLiteral, Class<? extends Annotation> annotationType) {
 return new Key<T>(typeLiteral, strategyFor(annotationType));
}

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

/** Gets a key for an injection type and an annotation type. */
public static <T> Key<T> get(Class<T> type, Class<? extends Annotation> annotationType) {
 return new Key<T>(type, strategyFor(annotationType));
}

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

/** Gets a key for an injection type and an annotation. */
public static <T> Key<T> get(TypeLiteral<T> typeLiteral, Annotation annotation) {
 return new Key<T>(typeLiteral, strategyFor(annotation));
}

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

/** Gets a key for an injection type and an annotation. */
public static <T> Key<T> get(Class<T> type, Annotation annotation) {
 return new Key<T>(type, strategyFor(annotation));
}

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

/** Gets a key for an injection type and an annotation type. */
public static Key<?> get(Type type, Class<? extends Annotation> annotationType) {
 return new Key<Object>(type, strategyFor(annotationType));
}

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

/** Gets a key for an injection type and an annotation. */
public static Key<?> get(Type type, Annotation annotation) {
 return new Key<Object>(type, strategyFor(annotation));
}

代码示例来源: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/guice

/** Gets the strategy for an annotation type. */
static AnnotationStrategy strategyFor(Class<? extends Annotation> annotationType) {
 annotationType = Annotations.canonicalizeIfNamed(annotationType);
 if (isAllDefaultMethods(annotationType)) {
  return strategyFor(generateAnnotation(annotationType));
 }
 checkNotNull(annotationType, "annotation type");
 ensureRetainedAtRuntime(annotationType);
 ensureIsBindingAnnotation(annotationType);
 return new AnnotationTypeStrategy(annotationType, null);
}

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

/**
 * Gets a key for an injection type and an annotation.
 */
public static <T> Key<T> get(Class<T> type, Annotation annotation) {
 return new SimpleKey<T>(type, strategyFor(annotation));
}

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

/**
 * Gets a key for an injection type and an annotation type.
 */
public static Key<?> get(Type type,
  Class<? extends Annotation> annotationType) {
 return new SimpleKey<Object>(type, strategyFor(annotationType));
}

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

/**
 * Gets a key for an injection type and an annotation type.
 */
public static <T> Key<T> get(Class<T> type,
  Class<? extends Annotation> annotationType) {
 return new Key<T>(type, strategyFor(annotationType));
}

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

/**
 * Gets a key for an injection type and an annotation type.
 */
public static <T> Key<T> get(TypeLiteral<T> typeLiteral,
  Class<? extends Annotation> annotationType) {
 return new Key<T>(typeLiteral, strategyFor(annotationType));
}

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

/**
 * Gets a key for an injection type and an annotation type.
 */
public static <T> Key<T> get(Class<T> type,
  Class<? extends Annotation> annotationType) {
 return new Key<T>(type, strategyFor(annotationType));
}

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

/**
 * Gets a key for an injection type and an annotation type.
 */
public static <T> Key<T> get(Class<T> type,
  Class<? extends Annotation> annotationType) {
 return new SimpleKey<T>(type, strategyFor(annotationType));
}

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

/**
 * Gets a key for an injection type and an annotation.
 */
public static Key<?> get(Type type, Annotation annotation) {
 return new Key<Object>(type, strategyFor(annotation));
}

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

/**
 * Gets a key for an injection type and an annotation type.
 */
public static <T> Key<T> get(TypeLiteral<T> typeLiteral,
  Class<? extends Annotation> annotationType) {
 return new Key<T>(typeLiteral, strategyFor(annotationType));
}

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

public ConstantBindingBuilder annotatedWith(Annotation annotation) {
 Objects.nonNull(annotation, "annotation");
 validateAnnotation(annotation.annotationType());
 annotationStrategy = Key.strategyFor(annotation);
 return this;
}

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

/** Gets the strategy for an annotation type. */
static AnnotationStrategy strategyFor(Class<? extends Annotation> annotationType) {
 annotationType = Annotations.canonicalizeIfNamed(annotationType);
 if (isAllDefaultMethods(annotationType)) {
  return strategyFor(generateAnnotation(annotationType));
 }
 checkNotNull(annotationType, "annotation type");
 ensureRetainedAtRuntime(annotationType);
 ensureIsBindingAnnotation(annotationType);
 return new AnnotationTypeStrategy(annotationType, null);
}

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

/** Gets the strategy for an annotation type. */
static AnnotationStrategy strategyFor(Class<? extends Annotation> annotationType) {
 annotationType = Annotations.canonicalizeIfNamed(annotationType);
 if (isAllDefaultMethods(annotationType)) {
  return strategyFor(generateAnnotation(annotationType));
 }
 checkNotNull(annotationType, "annotation type");
 ensureRetainedAtRuntime(annotationType);
 ensureIsBindingAnnotation(annotationType);
 return new AnnotationTypeStrategy(annotationType, null);
}

相关文章