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

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

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

Annotations.isMarker介绍

[英]Returns true if the given annotation type has no attributes.
[中]如果给定的注释类型没有属性,则返回true。

代码示例

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

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

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

/**
  * Returns the name the binding should use. This is based on the annotation. If the annotation has
  * an instance and is not a marker annotation, we ask the annotation for its toString. If it was a
  * marker annotation or just an annotation type, we use the annotation's name. Otherwise, the name
  * is the empty string.
  */
 public static String nameOf(Key<?> key) {
  Annotation annotation = key.getAnnotation();
  Class<? extends Annotation> annotationType = key.getAnnotationType();
  if (annotation != null && !isMarker(annotationType)) {
   return key.getAnnotation().toString();
  } else if (key.getAnnotationType() != null) {
   return "@" + key.getAnnotationType().getName();
  } else {
   return "";
  }
 }
}

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

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

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

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

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

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

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

/**
 * Returns the name the set should use.  This is based on the annotation.
 * If the annotation has an instance and is not a marker annotation,
 * we ask the annotation for its toString.  If it was a marker annotation
 * or just an annotation type, we use the annotation's name. Otherwise,
 * the name is the empty string.
 */
private String nameOf(Key<?> key) {
 Annotation annotation = setKey.getAnnotation();
 Class<? extends Annotation> annotationType = setKey.getAnnotationType();      
 if (annotation != null && !Annotations.isMarker(annotationType)) {
  return setKey.getAnnotation().toString();
 } else if(setKey.getAnnotationType() != null) {
  return "@" + setKey.getAnnotationType().getName();
 } else {
  return "";
 }
}

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

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

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

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

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

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

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

/**
  * Returns the name the binding should use. This is based on the annotation. If the annotation has
  * an instance and is not a marker annotation, we ask the annotation for its toString. If it was a
  * marker annotation or just an annotation type, we use the annotation's name. Otherwise, the name
  * is the empty string.
  */
 public static String nameOf(Key<?> key) {
  Annotation annotation = key.getAnnotation();
  Class<? extends Annotation> annotationType = key.getAnnotationType();
  if (annotation != null && !isMarker(annotationType)) {
   return key.getAnnotation().toString();
  } else if (key.getAnnotationType() != null) {
   return "@" + key.getAnnotationType().getName();
  } else {
   return "";
  }
 }
}

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

/**
  * Returns the name the binding should use. This is based on the annotation. If the annotation has
  * an instance and is not a marker annotation, we ask the annotation for its toString. If it was a
  * marker annotation or just an annotation type, we use the annotation's name. Otherwise, the name
  * is the empty string.
  */
 public static String nameOf(Key<?> key) {
  Annotation annotation = key.getAnnotation();
  Class<? extends Annotation> annotationType = key.getAnnotationType();
  if (annotation != null && !isMarker(annotationType)) {
   return key.getAnnotation().toString();
  } else if (key.getAnnotationType() != null) {
   return "@" + key.getAnnotationType().getName();
  } else {
   return "";
  }
 }
}

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

/**
 * Returns the name the binding should use.  This is based on the annotation.
 * If the annotation has an instance and is not a marker annotation,
 * we ask the annotation for its toString.  If it was a marker annotation
 * or just an annotation type, we use the annotation's name. Otherwise,
 * the name is the empty string.
 */
static String nameOf(Key<?> key) {
  Annotation annotation = key.getAnnotation();
  Class<? extends Annotation> annotationType = key.getAnnotationType();
  if (annotation != null && !Annotations.isMarker(annotationType)) {
    return key.getAnnotation().toString();
  } else if (key.getAnnotationType() != null) {
    return "@" + key.getAnnotationType().getName();
  } else {
    return "";
  }
}

相关文章