ColoredString implements EnhancedString { String getColoredString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < plain.length; i++) { if (codes[i] != null) { if (codes[i].indexOf(CR) > -1 || codes[i].indexOf(LF) > -1) { sb.append(codes[i]); } else { sb.append(codes[i]).append(plain[i]); } } else { sb.append(plain[i]); } } if (codes[codes.length - 1] != null) sb.append(codes[codes.length - 1]); return sb.toString(); } ColoredString(String s); private  ColoredString(char[] plain, String[] codes); int length(); char charAt(int i); CharSequence subSequence(int i, int j); @Override @NotNull String toString(); @Override ColoredString replaceText(Pattern p, String rText); ColoredString patternToLower(Pattern p); ColoredString patternToUpper(Pattern p); @Override boolean equals(Object obj); @Override String getRaw();  }
@Test public void testGetColoredString() { assertEquals(original, testCs.getColoredString()); }
@Test public void testColoredStringWithFormatAtEnd() { String test = "This is a string ending with format.&3"; ColoredString cs = new ColoredString(test); assertEquals(cs.getColoredString(), test); }