@Nonnull
	static String export(@Nonnull Mappings mappings, @Nonnull String inputNamespace,
	                     @Nonnull List<String> outputNamespaces, @Nonnull Function<StringWriter, MappingVisitor> writerFactory) throws InvalidMappingException {
		MemoryMappingTree tree = new MemoryMappingTree();
		IntermediateMappings intermediate = mappings.exportIntermediate();
		try {
			tree.visitNamespaces(inputNamespace, outputNamespaces);
			for (ClassMapping classMapping : intermediate.getClasses().values()) {
				String classOriginalName = classMapping.getOldName();
				tree.visitClass(classOriginalName);
				tree.visitDstName(MappedElementKind.CLASS, 0, classMapping.getNewName());

				List<FieldMapping> fieldMappings = intermediate.getClassFieldMappings(classOriginalName);
				for (FieldMapping fieldMapping : fieldMappings) {
					tree.visitField(fieldMapping.getOldName(), fieldMapping.getDesc());
					tree.visitDstName(MappedElementKind.FIELD, 0, fieldMapping.getNewName());
				}

				List<MethodMapping> methodMappings = intermediate.getClassMethodMappings(classOriginalName);
				for (MethodMapping methodMapping : methodMappings) {
					tree.visitMethod(methodMapping.getOldName(), methodMapping.getDesc());
					tree.visitDstName(MappedElementKind.METHOD, 0, methodMapping.getNewName());
				}
			}

			// Write the mappings in natural sorted order by name.
			// Intermediate mappings are *typically* sorted, but it is not a guarantee.
			VisitOrder order = VisitOrder.createByName();
			StringWriter sw = new StringWriter();
			MappingVisitor writer = writerFactory.apply(sw);
			tree.accept(writer, order);
			return sw.toString();
		} catch (Throwable t) {
			throw new InvalidMappingException(t);
		}
	}
A utility for utilizing mapping-io to write mapping text formats.

@param mappings
		Mappings to export to text.
@param inputNamespace
		Input column name.
@param outputNamespaces
		Output column names.
@param writerFactory
		Factory to create a mapping-io format writer.

@return Text representation of mappings in the format provided by the writer factory.

@throws InvalidMappingException
		When writing the mappings encounters any failure.
recaf-core/src/main/java/software/coley/recaf/services/mapping/format/MappingFileFormat.java