Skip to content

Commit d9cf223

Browse files
committed
AbstractLocation: implement a sensible toString()
This will make it easier to understand Location objects when debugging.
1 parent 6c094f7 commit d9cf223

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main/java/org/scijava/io/location/AbstractLocation.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
package org.scijava.io.location;
3434

35+
import java.net.URI;
3536
import java.util.Objects;
3637

3738
/**
@@ -58,4 +59,13 @@ public boolean equals(final Object obj) {
5859
return Objects.equals(getURI(), other.getURI());
5960
}
6061

62+
@Override
63+
public String toString() {
64+
final String prefix = getClass().getSimpleName() + ":";
65+
final URI uri = getURI();
66+
if (uri != null) return prefix + uri;
67+
final String name = getName();
68+
if (name != null) return prefix + name;
69+
return prefix + defaultName();
70+
}
6171
}

0 commit comments

Comments
 (0)