com.google.inject.internal.Annotations.findScopeAnnotation()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(119)

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

Annotations.findScopeAnnotation介绍

[英]Returns the scope annotation on type, or null if none is specified.
[中]返回类型的范围注释,如果未指定,则返回null。

代码示例

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

/** Returns the scope annotation on {@code type}, or null if none is specified. */
public static Class<? extends Annotation> findScopeAnnotation(
  Errors errors, Class<?> implementation) {
 return findScopeAnnotation(errors, implementation.getAnnotations());
}

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

/**
 * Adds an error if there is a misplaced annotations on {@code type}. Scoping annotations are not
 * allowed on abstract classes or interfaces.
 */
public static void checkForMisplacedScopeAnnotations(
  Class<?> type, Object source, Errors errors) {
 if (Classes.isConcrete(type)) {
  return;
 }
 Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type);
 if (scopeAnnotation != null
   // We let Dagger Components through to aid migrations.
   && !containsComponentAnnotation(type.getAnnotations())) {
  errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source);
 }
}

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

private <T> ProviderMethod<T> createProviderMethod(
  Binder binder, Method method, Annotation annotation) {
 binder = binder.withSource(method);
 Errors errors = new Errors(method);
 // prepare the parameter providers
 InjectionPoint point = InjectionPoint.forMethod(method, typeLiteral);
 @SuppressWarnings("unchecked") // Define T as the method's return type.
 TypeLiteral<T> returnType = (TypeLiteral<T>) typeLiteral.getReturnType(method);
 Key<T> key = getKey(errors, returnType, method, method.getAnnotations());
 try {
  key = scanner.prepareMethod(binder, annotation, key, point);
 } catch (Throwable t) {
  binder.addError(t);
 }
 Class<? extends Annotation> scopeAnnotation =
   Annotations.findScopeAnnotation(errors, method.getAnnotations());
 for (Message message : errors.getMessages()) {
  binder.addError(message);
 }
 return ProviderMethod.create(
   key,
   method,
   delegate,
   ImmutableSet.copyOf(point.getDependencies()),
   scopeAnnotation,
   skipFastClassGeneration,
   annotation);
}

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

Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, annotatedType);
if (scopeAnnotation != null) {
 scoping =

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

/** Returns the scope annotation on {@code type}, or null if none is specified. */
public static Class<? extends Annotation> findScopeAnnotation(
  Errors errors, Class<?> implementation) {
 return findScopeAnnotation(errors, implementation.getAnnotations());
}

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

/** Returns the scope annotation on {@code type}, or null if none is specified. */
public static Class<? extends Annotation> findScopeAnnotation(
  Errors errors, Class<?> implementation) {
 return findScopeAnnotation(errors, implementation.getAnnotations());
}

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

/** Returns the scope annotation on {@code type}, or null if none is specified. */
public static Class<? extends Annotation> findScopeAnnotation(
  Errors errors, Class<?> implementation) {
 return findScopeAnnotation(errors, implementation.getAnnotations());
}

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

/** Returns the scope annotation on {@code type}, or null if none is specified. */
public static Class<? extends Annotation> findScopeAnnotation(
  Errors errors, Class<?> implementation) {
 return findScopeAnnotation(errors, implementation.getAnnotations());
}

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

/** Returns the scope annotation on {@code type}, or null if none is specified. */
public static Class<? extends Annotation> findScopeAnnotation(
  Errors errors, Class<?> implementation) {
 return findScopeAnnotation(errors, implementation.getAnnotations());
}

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

/**
 * Returns the scope annotation on {@code type}, or null if none is specified.
 */
public static Class<? extends Annotation> findScopeAnnotation(
    Errors errors, Class<?> implementation) {
  return findScopeAnnotation(errors, implementation.getAnnotations());
}

代码示例来源:origin: org.immutables/common

private void verifyAbsenseOfScopeAnnotation(Errors methodErrors, Annotation[] annotations, Object source) {
 @Nullable
 Class<? extends Annotation> methodScopeAnnotation =
   Annotations.findScopeAnnotation(methodErrors, annotations);
 if (methodScopeAnnotation != null) {
  methodErrors.addMessage(
    "Misplaced scope annotation @%s on method @%s %s.%n    Scope annotation will be inherited from enclosing class %s",
    methodScopeAnnotation.getSimpleName(),
    EventuallyProvides.class.getSimpleName(),
    source,
    providersClass.getSimpleName());
 }
}

代码示例来源:origin: org.immutables/common

EventualProvider(
  Invokable<T, ?> method,
  boolean exposedBinding,
  List<Dependency<ListenableFuture<?>>> dependencies,
  Key<ListenableFuture<?>> bindingKey,
  @Nullable Class<? extends Annotation> scopeAnnotation,
  Object source) {
 this.method = method;
 this.source = source;
 this.exposedBinding = exposedBinding;
 this.bindingKey = bindingKey;
 this.scopeAnnotation = scopeAnnotation;
 this.dependencies = ImmutableList.copyOf(dependencies);
 this.dependencySet = ImmutableSet.<Dependency<?>>builder()
   .addAll(dependencies)
   .add(Dependency.get(Key.get(Injector.class)))
   .add(Dependency.get(Key.get(type.getRawType())))
   .build();
}

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

/**
 * Adds an error if there is a misplaced annotations on {@code type}. Scoping
 * annotations are not allowed on abstract classes or interfaces.
 */
public static void checkForMisplacedScopeAnnotations(
  Class<?> type, Object source, Errors errors) {
 if (Classes.isConcrete(type)) {
  return;
 }
 Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type);
 if (scopeAnnotation != null) {
  errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source);
 }
}

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

/**
 * Adds an error if there is a misplaced annotations on {@code type}. Scoping
 * annotations are not allowed on abstract classes or interfaces.
 */
public static void checkForMisplacedScopeAnnotations(
  Class<?> type, Object source, Errors errors) {
 if (Classes.isConcrete(type)) {
  return;
 }
 Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type);
 if (scopeAnnotation != null) {
  errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source);
 }
}

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

/**
 * Adds an error if there is a misplaced annotations on {@code type}. Scoping
 * annotations are not allowed on abstract classes or interfaces.
 */
public static void checkForMisplacedScopeAnnotations(
  Class<?> type, Object source, Errors errors) {
 if (Classes.isConcrete(type)) {
  return;
 }
 Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type);
 if (scopeAnnotation != null) {
  errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source);
 }
}

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

/**
 * Adds an error if there is a misplaced annotations on {@code type}. Scoping annotations are not
 * allowed on abstract classes or interfaces.
 */
public static void checkForMisplacedScopeAnnotations(
  Class<?> type, Object source, Errors errors) {
 if (Classes.isConcrete(type)) {
  return;
 }
 Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type);
 if (scopeAnnotation != null
   // We let Dagger Components through to aid migrations.
   && !containsComponentAnnotation(type.getAnnotations())) {
  errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source);
 }
}

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

/**
 * Adds an error if there is a misplaced annotations on {@code type}. Scoping annotations are not
 * allowed on abstract classes or interfaces.
 */
public static void checkForMisplacedScopeAnnotations(
  Class<?> type, Object source, Errors errors) {
 if (Classes.isConcrete(type)) {
  return;
 }
 Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type);
 if (scopeAnnotation != null
   // We let Dagger Components through to aid migrations.
   && !containsComponentAnnotation(type.getAnnotations())) {
  errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source);
 }
}

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

/**
 * Adds an error if there is a misplaced annotations on {@code type}. Scoping
 * annotations are not allowed on abstract classes or interfaces.
 */
public static void checkForMisplacedScopeAnnotations(
    Class<?> type, Object source, Errors errors) {
  if (Classes.isConcrete(type)) {
    return;
  }
  Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type);
  if (scopeAnnotation != null
      // We let Dagger Components through to aid migrations.
      && !containsComponentAnnotation(type.getAnnotations())) {
    errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source);
  }
}

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

private <T> ProviderMethod<T> createProviderMethod(
  Binder binder, Method method, Annotation annotation) {
 binder = binder.withSource(method);
 Errors errors = new Errors(method);
 // prepare the parameter providers
 InjectionPoint point = InjectionPoint.forMethod(method, typeLiteral);
 @SuppressWarnings("unchecked") // Define T as the method's return type.
 TypeLiteral<T> returnType = (TypeLiteral<T>) typeLiteral.getReturnType(method);
 Key<T> key = getKey(errors, returnType, method, method.getAnnotations());
 try {
  key = scanner.prepareMethod(binder, annotation, key, point);
 } catch (Throwable t) {
  binder.addError(t);
 }
 Class<? extends Annotation> scopeAnnotation =
   Annotations.findScopeAnnotation(errors, method.getAnnotations());
 for (Message message : errors.getMessages()) {
  binder.addError(message);
 }
 return ProviderMethod.create(
   key,
   method,
   delegate,
   ImmutableSet.copyOf(point.getDependencies()),
   scopeAnnotation,
   skipFastClassGeneration,
   annotation);
}

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

private <T> ProviderMethod<T> createProviderMethod(
  Binder binder, Method method, Annotation annotation) {
 binder = binder.withSource(method);
 Errors errors = new Errors(method);
 // prepare the parameter providers
 InjectionPoint point = InjectionPoint.forMethod(method, typeLiteral);
 @SuppressWarnings("unchecked") // Define T as the method's return type.
 TypeLiteral<T> returnType = (TypeLiteral<T>) typeLiteral.getReturnType(method);
 Key<T> key = getKey(errors, returnType, method, method.getAnnotations());
 try {
  key = scanner.prepareMethod(binder, annotation, key, point);
 } catch (Throwable t) {
  binder.addError(t);
 }
 Class<? extends Annotation> scopeAnnotation =
   Annotations.findScopeAnnotation(errors, method.getAnnotations());
 for (Message message : errors.getMessages()) {
  binder.addError(message);
 }
 return ProviderMethod.create(
   key,
   method,
   delegate,
   ImmutableSet.copyOf(point.getDependencies()),
   scopeAnnotation,
   skipFastClassGeneration,
   annotation);
}

相关文章