TerminalString implements Comparable<TerminalString> { public TerminalString(String chars, TerminalColor color, TerminalTextStyle style) { this.characters = chars; if(color != null) this.color = color; else this.color = new TerminalColor(); if(style != null) this.style = style; else this.style = new TerminalTextStyle(); } TerminalString(String chars, TerminalColor color, TerminalTextStyle style);  TerminalString(String chars, TerminalColor color);  TerminalString(String chars, TerminalTextStyle style);  TerminalString(String chars);  TerminalString(String chars, boolean ignoreRendering); String getCharacters(); void setCharacters(String chars); boolean containSpaces(); void switchSpacesToEscapedSpaces(); TerminalTextStyle getStyle(); int getANSILength(); TerminalString cloneRenderingAttributes(String chars); boolean isFormatted(); String toString(TerminalString prev); @Override String toString(); void write(PrintStream out); boolean equalsIgnoreCharacter(TerminalString that); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(TerminalString terminalString);  }
@Test public void testTerminalString() { TerminalString string = new TerminalString("foo"); assertFalse(string.containSpaces()); assertFalse(string.isFormatted()); assertEquals("foo", string.getCharacters()); string = new TerminalString("foo bar", new TerminalColor(Color.BLACK, Color.WHITE)); assertTrue(string.containSpaces()); assertTrue(string.isFormatted()); assertEquals("foo bar", string.getCharacters()); string.switchSpacesToEscapedSpaces(); assertEquals("foo\\ bar", string.getCharacters()); assertEquals(ANSI.START+";30;47mfoo\\ bar"+ANSI.RESET, string.toString()); string = new TerminalString("foo bar", true); assertTrue(string.containSpaces()); assertFalse(string.isFormatted()); assertEquals("foo bar", string.getCharacters()); assertEquals(0, string.getANSILength()); }