diff --git a/lovelace-util/src/main/java/lovelace/util/Range.java b/lovelace-util/src/main/java/lovelace/util/Range.java index 0156068c6..33ac77b5b 100644 --- a/lovelace-util/src/main/java/lovelace/util/Range.java +++ b/lovelace-util/src/main/java/lovelace/util/Range.java @@ -40,6 +40,11 @@ public RangeIterator(final Range range) { upperBound = range.upperBound; } + @Override + public String toString() { + return "RangeIterator (" + current + ", " + upperBound + ")"; + } + @Override public boolean hasNext() { return current < upperBound; diff --git a/lovelace-util/src/main/java/lovelace/util/ResourceInputStream.java b/lovelace-util/src/main/java/lovelace/util/ResourceInputStream.java index b795d9ae7..f86155aa5 100644 --- a/lovelace-util/src/main/java/lovelace/util/ResourceInputStream.java +++ b/lovelace-util/src/main/java/lovelace/util/ResourceInputStream.java @@ -17,12 +17,14 @@ */ public class ResourceInputStream extends InputStream { private final InputStream wrapped; + private final String filename; public ResourceInputStream(final String filename) throws NoSuchFileException { this(filename, ResourceInputStream.class); } public ResourceInputStream(final String filename, final Class sourceClass) throws NoSuchFileException { + this.filename = filename; InputStream temp; try { // N.B. we don't use Files::newInputStream because we'd have to either catch or throw IOException. @@ -85,4 +87,9 @@ public int available() throws IOException { public void close() throws IOException { wrapped.close(); } + + @Override + public String toString() { + return "ResourceInputStream for: " + filename; + } } diff --git a/lovelace-util/src/main/java/lovelace/util/SimpleCardLayout.java b/lovelace-util/src/main/java/lovelace/util/SimpleCardLayout.java index 2a22fb230..52e220d1a 100644 --- a/lovelace-util/src/main/java/lovelace/util/SimpleCardLayout.java +++ b/lovelace-util/src/main/java/lovelace/util/SimpleCardLayout.java @@ -8,6 +8,7 @@ * A convenience wrapper around {@link CardLayout} so callers don't have to * pass around a reference to the laid-out container to flip between cards. */ +@SuppressWarnings("ClassHasNoToStringMethod") // CardLayout toString suffices public class SimpleCardLayout extends CardLayout { @Serial private static final long serialVersionUID = 1; diff --git a/lovelace-util/src/main/java/lovelace/util/SimplePair.java b/lovelace-util/src/main/java/lovelace/util/SimplePair.java index b78037f75..18a3548ba 100644 --- a/lovelace-util/src/main/java/lovelace/util/SimplePair.java +++ b/lovelace-util/src/main/java/lovelace/util/SimplePair.java @@ -45,4 +45,9 @@ public int hashCode() { public static SimplePair of(final Type first, final Type second) { return new SimplePair<>(first, second); } + + @Override + public String toString() { + return "SimplePair["+ first + "," + second + "]"; + } } diff --git a/lovelace-util/src/main/java/lovelace/util/StreamingLabel.java b/lovelace-util/src/main/java/lovelace/util/StreamingLabel.java index 58108860e..94d1862ba 100644 --- a/lovelace-util/src/main/java/lovelace/util/StreamingLabel.java +++ b/lovelace-util/src/main/java/lovelace/util/StreamingLabel.java @@ -26,6 +26,11 @@ public String getColorName() { LabelTextColor(final String color) { colorName = color; } + + @Override + public String toString() { + return colorName; + } } private final StringBuilder buffer = new StringBuilder(); @@ -55,4 +60,9 @@ public void appendLine(final String string) { setText("" + buffer + ""); repaint(); } + + @Override + public String toString() { + return "StreamingLabel with " + buffer.length() + " characters."; + } } diff --git a/lovelace-util/src/main/java/lovelace/util/TypeStream.java b/lovelace-util/src/main/java/lovelace/util/TypeStream.java index c44e401e2..e18526b9b 100644 --- a/lovelace-util/src/main/java/lovelace/util/TypeStream.java +++ b/lovelace-util/src/main/java/lovelace/util/TypeStream.java @@ -26,16 +26,23 @@ public Iterator> iterator() { return new TypeIterator(obj, cache); } + @Override + public String toString() { + return "TypeStream for " + obj; + } + private static final class TypeIterator implements Iterator> { private final LinkedList> ourCopy; private final List> cache; private final Collection> classes = new HashSet<>(); private final Queue> queue = new LinkedList<>(); + private final String str; public TypeIterator(final Object obj, final List> cache) { this.cache = cache; ourCopy = new LinkedList<>(cache); queue.add(obj.getClass()); + str = "TypeStream iterator for: " + obj; } @Override @@ -63,5 +70,10 @@ public Class next() { } throw new NoSuchElementException("No more supertypes"); } + + @Override + public String toString() { + return str; + } } } diff --git a/lovelace-util/src/main/java/lovelace/util/TypesafeXMLEventReader.java b/lovelace-util/src/main/java/lovelace/util/TypesafeXMLEventReader.java index 6e69b2ef9..046ed50c4 100644 --- a/lovelace-util/src/main/java/lovelace/util/TypesafeXMLEventReader.java +++ b/lovelace-util/src/main/java/lovelace/util/TypesafeXMLEventReader.java @@ -114,4 +114,9 @@ public boolean hasNext() { return wrapped.hasNext(); } } + + @Override + public String toString() { + return "TypesafeXMLEventReader wrapping: " + wrapped; + } }