package com.ankurm.otel; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; /** Collects lines and writes output/NN-name[-on-4.1.2].txt. Tests assert what they write. */ final class Transcript { static final String LABEL = System.getProperty("boot.label", "4.2.0-RC1"); static boolean is42() { return LABEL.startsWith("4.2"); } private final List lines = new ArrayList<>(); private final Path file; Transcript(String name) { String suffix = is42() ? "" : "-on-" + LABEL; this.file = Path.of("output", name + suffix + ".txt"); line("# " + name + " (Spring Boot " + LABEL + ", JDK " + Runtime.version().feature() + ")"); } Transcript line(String s) { lines.add(s); return this; } void write() { try { Files.createDirectories(file.getParent()); Files.write(file, lines); } catch (IOException ex) { throw new IllegalStateException(ex); } } }