+ private final List<Character> chars = new ArrayList<>();
+
+ public String2 clear(){
+ chars.clear();
+ return this;
+ }
+
+ public String2(String value) {
+ append(value);
+ }
+
+ public String2() {
+ }
+
+ public String2 repeat(int count){
+ if (count > 0) {
+ String value = toString();
+
+ for (int i = 1; i < count; i++)
+ append(value);
+ } else {
+ clear();
+ }
+ return this;
+ }
+
+ public String2 prepend(final String prefix) {
+ if (prefix == null)
+ return this;
+
+ int i = 0;
+ for (final char c : prefix.toCharArray())
+ chars.add(i++, c);
+
+ return this;
+ }
+
+ public String2 append(final String suffix) {
+ if (suffix == null)
+ return this;
+
+ for (final char c : suffix.toCharArray())
+ chars.add(c);
+
+ return this;
+ }
+
+ public String2 appendWithSeparator(String separator, final String suffix) {
+ if (!isEmpty())
+ append(separator);
+
+ append(suffix);
+
+ return this;
+ }
+
+ public String2 append(String s, int times) {
+ for (int i = 0; i < times; i++) append(s);
+ return this;
+ }
+
+
+ /**
+ * Cut given amount of characters from the left of the string.
+ *
+ * @param cutAmount of characters to cut
+ * @return part that was cut.
+ */
+ public String2 trimPrefix(final int cutAmount) {
+
+ int actualCutAmount = cutAmount;
+
+ if (actualCutAmount > getLength())
+ actualCutAmount = getLength();
+
+ chars.subList(0, actualCutAmount).clear();
+
+ return this;
+ }
+
+ public String2 trimPrefixIfExists(String prefix) {
+ if (prefix == null)
+ return this;
+
+ if (hasPrefix(prefix))
+ trimPrefix(prefix.length());
+
+ return this;
+ }
+
+ public String2 trimSuffixIfExists(String suffix) {
+ if (hasSuffix(suffix))
+ trimSuffix(suffix.length());
+
+ return this;
+ }
+
+ public String2 trimSuffix(int charsToTrim) {
+
+ if (charsToTrim > chars.size()) {
+ chars.clear();
+ return this;
+ }
+
+ for (int i = 0; i < charsToTrim; i++)
+ chars.remove(chars.size() - 1);