|
@@ -16,6 +16,10 @@ import java.util.NoSuchElementException;
|
|
* @param <T>
|
|
* @param <T>
|
|
* The type of colors;
|
|
* The type of colors;
|
|
*/
|
|
*/
|
|
|
|
+/*
|
|
|
|
+ * I cannot be moved to com.hgames.rhogue until I depend on IFilter, which I
|
|
|
|
+ * didn't wrote
|
|
|
|
+ */
|
|
public interface IColoredString<T> extends Iterable<IColoredString.Bucket<T>> {
|
|
public interface IColoredString<T> extends Iterable<IColoredString.Bucket<T>> {
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -188,7 +192,7 @@ public interface IColoredString<T> extends Iterable<IColoredString.Bucket<T>> {
|
|
* @param <T>
|
|
* @param <T>
|
|
* The type of colors
|
|
* The type of colors
|
|
*/
|
|
*/
|
|
- class Impl<T> implements IColoredString<T> {
|
|
|
|
|
|
+ public final class Impl<T> implements IColoredString<T> {
|
|
|
|
|
|
protected final LinkedList<Bucket<T>> fragments;
|
|
protected final LinkedList<Bucket<T>> fragments;
|
|
|
|
|
|
@@ -786,7 +790,7 @@ public interface IColoredString<T> extends Iterable<IColoredString.Bucket<T>> {
|
|
* @param <T>
|
|
* @param <T>
|
|
* The type of colors;
|
|
* The type of colors;
|
|
*/
|
|
*/
|
|
- class Bucket<T> {
|
|
|
|
|
|
+ final class Bucket<T> {
|
|
|
|
|
|
protected final String text;
|
|
protected final String text;
|
|
protected final/* @Nullable */T color;
|
|
protected final/* @Nullable */T color;
|
|
@@ -797,16 +801,16 @@ public interface IColoredString<T> extends Iterable<IColoredString.Bucket<T>> {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @param text
|
|
|
|
- * @return An instance whose text is {@code this.text + text}. Color is
|
|
|
|
|
|
+ * @param toadd
|
|
|
|
+ * @return An instance whose text is {@code this.text + toadd}. Color is
|
|
* unchanged.
|
|
* unchanged.
|
|
*/
|
|
*/
|
|
- public Bucket<T> append(String text) {
|
|
|
|
- if (text == null || text.isEmpty())
|
|
|
|
|
|
+ public Bucket<T> append(String toadd) {
|
|
|
|
+ if (toadd == null || toadd.isEmpty())
|
|
/* Let's save an allocation */
|
|
/* Let's save an allocation */
|
|
return this;
|
|
return this;
|
|
else
|
|
else
|
|
- return new Bucket<>(this.text + text, color);
|
|
|
|
|
|
+ return new Bucket<T>(this.text + toadd, color);
|
|
}
|
|
}
|
|
|
|
|
|
public Bucket<T> setLength(int l) {
|
|
public Bucket<T> setLength(int l) {
|
|
@@ -814,7 +818,7 @@ public interface IColoredString<T> extends Iterable<IColoredString.Bucket<T>> {
|
|
if (here <= l)
|
|
if (here <= l)
|
|
return this;
|
|
return this;
|
|
else
|
|
else
|
|
- return new Bucket<>(text.substring(0, l), color);
|
|
|
|
|
|
+ return new Bucket<T>(text.substring(0, l), color);
|
|
}
|
|
}
|
|
|
|
|
|
public Bucket<T> setColor(T t) {
|
|
public Bucket<T> setColor(T t) {
|