java类java.lang.annotation.ElementType的实例源码

AnnotationLister.java 文件源码 项目:JCL 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Inspects a class annotation.
 *
 * @param cf {@code non-null;} class file
 * @param ann {@code non-null;} annotation
 */
private void visitClassAnnotation(DirectClassFile cf,
        BaseAnnotations ann) {

    if (!args.eTypes.contains(ElementType.TYPE)) {
        return;
    }

    for (Annotation anAnn : ann.getAnnotations().getAnnotations()) {
        String annClassName
                = anAnn.getType().getClassType().getClassName();
        if (args.aclass.equals(annClassName)) {
            printMatch(cf);
        }
    }
}
Annotations.java 文件源码 项目:GitHub 阅读 23 收藏 0 点赞 0 评论 0
static List<CharSequence> getAnnotationLines(
    Element element,
    Set<String> includeAnnotations,
    boolean includeJacksonAnnotations,
    ElementType elementType,
    Function<String, String> importsResolver,
    @Nullable NullabilityAnnotationInfo nullability) {
  return getAnnotationLines(element,
      includeAnnotations,
      false,
      includeJacksonAnnotations,
      elementType,
      importsResolver,
      nullability);
}
Annotations.java 文件源码 项目:GitHub 阅读 28 收藏 0 点赞 0 评论 0
static List<CharSequence> getAnnotationLines(
    Element element,
    Set<String> includeAnnotations,
    boolean includeAllAnnotations,
    boolean includeJacksonAnnotations,
    ElementType elementType,
    Function<String, String> importsResolver,
    @Nullable NullabilityAnnotationInfo nullability) {
  List<CharSequence> lines = Lists.newArrayList();

  Set<String> seenAnnotations = new HashSet<>();
  for (AnnotationMirror annotation : element.getAnnotationMirrors()) {
    TypeElement annotationElement = (TypeElement) annotation.getAnnotationType().asElement();

    if (annotationTypeMatches(element,
        annotationElement,
        includeAnnotations,
        includeAllAnnotations,
        includeJacksonAnnotations,
        seenAnnotations,
        lines,
        importsResolver,
        elementType,
        nullability)
        && annotationMatchesTarget(annotationElement, elementType)) {
      lines.add(AnnotationMirrors.toCharSequence(annotation, importsResolver));
    }
  }
  return lines;
}
ValueType.java 文件源码 项目:GitHub 阅读 30 收藏 0 点赞 0 评论 0
public List<CharSequence> getBuilderAnnotations() {
  Optional<DeclaringType> declaringType = constitution.protoclass().declaringType();
  if (declaringType.isPresent() && declaringType.get().jacksonSerializeMode() == JacksonMode.BUILDER) {
    return Annotations.getAnnotationLines(
        element,
        Collections.<String>emptySet(),
        true,
        ElementType.TYPE,
        newTypeStringResolver(),
        null);
  }
  return ImmutableList.of();
}
ValueType.java 文件源码 项目:GitHub 阅读 28 收藏 0 点赞 0 评论 0
public List<CharSequence> passedAnnotations() {
  return Annotations.getAnnotationLines(
      element,
      Sets.union(
          constitution.style().passAnnotationsNames(),
          constitution.style().additionalJsonAnnotationsNames()),
      false,
      ElementType.TYPE,
      newTypeStringResolver(),
      null);
}
ValueAttribute.java 文件源码 项目:GitHub 阅读 32 收藏 0 点赞 0 评论 0
public List<CharSequence> getAnnotations() {
  if (containingType.isGenerateJacksonProperties()) {
    return extractAnnotationsForElement(
        ElementType.METHOD,
        protoclass().styles().style().passAnnotationsNames());

  }
  return Annotations.getAnnotationLines(element,
      protoclass().styles().style().passAnnotationsNames(),
      false,
      ElementType.METHOD,
      importsResolver,
      nullability);
}
ValueAttribute.java 文件源码 项目:GitHub 阅读 27 收藏 0 点赞 0 评论 0
public List<CharSequence> getFieldAnnotations() {
  return Annotations.getAnnotationLines(element,
      protoclass().styles().style().passAnnotationsNames(),
      false,
      ElementType.FIELD,
      importsResolver,
      null/* do not propagate nullable here */);
}
ValueAttribute.java 文件源码 项目:GitHub 阅读 30 收藏 0 点赞 0 评论 0
public CharSequence getConstructorParameterAnnotations() {
  List<CharSequence> annotations =
      Annotations.getAnnotationLines(element,
          protoclass().styles().style().passAnnotationsNames(),
          false,
          ElementType.PARAMETER,
          importsResolver,
          nullability);

  if (!annotations.isEmpty()) {
    return Joiner.on(' ').join(annotations).concat(" ");
  }

  return "";
}
NullabilityAnnotationInfo.java 文件源码 项目:GitHub 阅读 21 收藏 0 点赞 0 评论 0
@Value.Lazy
String asLocalPrefix() {
  boolean applicableToLocal = Annotations.annotationMatchesTarget(
      element(),
      ElementType.LOCAL_VARIABLE);

  return applicableToLocal
      ? asPrefix()
      : "";
}
CommandContextTest.java 文件源码 项目:oscm 阅读 24 收藏 0 点赞 0 评论 0
@Test
public void testGetEnumOptionalInvalid() {
    args.put("key", "CONSTRUCTOR");
    Set<ElementType> all = EnumSet.noneOf(ElementType.class);
    all.add(ElementType.FIELD);
    all.add(ElementType.METHOD);
    assertEquals(null, ctx.getEnumOptional("key", all));
}


问题


面经


文章

微信
公众号

扫码关注公众号