private Iterable<String> annotationsFrom(Element element) { List<String> annotations = new ArrayList<>(); for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) { String a = AnnotationMirrors.toCharSequence(annotationMirror).toString(); if (!a.startsWith(ENCODE_PACKAGE_PREFIX, 1)) { annotations.add(a); } } return annotations; }
private StringBuilder typeAnnotationsToBuffer(List<? extends AnnotationMirror> annotations, boolean nestedTypeUse) { StringBuilder annotationBuffer = new StringBuilder(100); for (AnnotationMirror annotationMirror : annotations) { boolean canBeAppliedToMethodAsWell = !nestedTypeUse // just to short circuit computation early && Annotations.annotationMatchesTarget(annotationMirror.getAnnotationType().asElement(), ElementType.METHOD); if (canBeAppliedToMethodAsWell) { // skip this type annotation on top type continue; } CharSequence sequence = AnnotationMirrors.toCharSequence(annotationMirror, importsResolver); if (!nullableTypeAnnotation && sequence.toString().endsWith(EPHEMERAL_ANNOTATION_NULLABLE)) { this.nullableTypeAnnotation = true; } annotationBuffer .append(sequence) .append(' '); } return annotationBuffer; }
private ImmutableMap<String, String> extractPlaceholderValues( AnnotationMirror annotation, Environment environment) { ImmutableMap.Builder<String, String> literals = ImmutableMap.builder(); for (Entry<? extends ExecutableElement, ? extends AnnotationValue> e : environment.processing() .getElementUtils() .getElementValuesWithDefaults(CachingElements.getDelegate(annotation)) .entrySet()) { String key = e.getKey().getSimpleName().toString(); String value = AnnotationMirrors.toCharSequence(e.getValue()).toString(); literals.put(key, value); } return literals.build(); }
public List<CharSequence> getJsonQualiferAnnotations() { if (jsonQualifierAnnotations == null) { List<CharSequence> annotationStrings = Collections.emptyList(); for (AnnotationMirror m : element.getAnnotationMirrors()) { if (MetaAnnotated.from(m, protoclass().environment()).isJsonQualifier()) { if (annotationStrings.isEmpty()) { annotationStrings = Lists.newArrayList(); } annotationStrings.add(AnnotationMirrors.toCharSequence(m)); } } jsonQualifierAnnotations = annotationStrings; } return jsonQualifierAnnotations; }
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; }
annotationCode.put( info.deduplicationKey, AnnotationMirrors.toCharSequence(presentAnnotation).toString());
lines.add(AnnotationMirrors.toCharSequence(metaAnnotation, importsResolver));