public @Nonnull String getFieldType(@Nonnull TypeImporter typeImporter) { final @Nonnull StringBuilder returnTypeAsString = new StringBuilder(); returnTypeAsString.append(ProcessingUtility.getAnnotationsAsString(FiniteIterable.of(getType().getAnnotationMirrors()), typeImporter)); returnTypeAsString.append(typeImporter.importIfPossible(getType())); return returnTypeAsString.toString(); }
@Impure @Override @NonWrittenRecipient public @Nonnull String importIfPossible(@Nonnull TypeMirror typeMirror) { return ProcessingUtility.getAnnotationsAsString(typeMirror, this) + importingTypeVisitor.visit(typeMirror); }
/** * Returns the annotations of the given type mirror with their values as a string. */ @Pure public static @Nonnull String getAnnotationsAsString(@Nonnull TypeMirror typeMirror, @NonCaptured @Modified @Nonnull TypeImporter typeImporter) { return getAnnotationsAsString(FiniteIterable.of(typeMirror.getAnnotationMirrors()), typeImporter); }
@Pure @Override public @Nonnull String visitDeclared(@Nonnull DeclaredType type, @Nullable Void none) { @Nonnull TypeElement typeElement = (TypeElement) type.asElement(); @Nonnull String nestedTypeName = ""; while (typeElement.getNestingKind() == NestingKind.MEMBER) { final @Nonnull Element enclosingElement = typeElement.getEnclosingElement(); if (enclosingElement instanceof TypeElement) { nestedTypeName = "." + typeElement.getSimpleName() + nestedTypeName; typeElement = (TypeElement) enclosingElement; } else { ProcessingLog.error("The enclosing element $ of the member type $ is not a type element.", enclosingElement, typeElement); break; } } return ProcessingUtility.getAnnotationsAsString(type, JavaFileGenerator.this) + importIfPossible(typeElement) + nestedTypeName + FiniteIterable.of(type.getTypeArguments()).map(this::visit).join(Brackets.POINTY, ""); }
/** * Returns all return type annotations of the method as a space-separated string. */ public @Nonnull String getReturnTypeAnnotations(@Nonnull TypeImporter typeImporter) { final @Nonnull TypeMirror typeMirror = StaticProcessingEnvironment.getTypeUtils().asMemberOf(getContainingType(), getElement()); final @Nonnull ExecutableType executableType = (ExecutableType) typeMirror; final @Nonnull TypeMirror returnType = executableType.getReturnType(); final @Nonnull String returnTypeAnnotationsAsString; if (returnType instanceof Type.AnnotatedType) { final Type.@Nonnull AnnotatedType annotatedType = (Type.AnnotatedType) returnType; returnTypeAnnotationsAsString = ProcessingUtility.getAnnotationsAsString(FiniteIterable.of(annotatedType.getAnnotationMirrors()), typeImporter); } else { returnTypeAnnotationsAsString = ""; } return returnTypeAnnotationsAsString; }