Skip to content

Commit 4b04c8b

Browse files
gab1onectrueden
authored andcommitted
Location: change default name to non-empty string
This avoids confusion when the Location implementation does not assign a name explicitly. Detecting that situation is now very easy. Signed-off-by: Curtis Rueden <[email protected]>
1 parent 172009d commit 4b04c8b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,20 @@ default URI getURI() {
7171
* @return The name, or an empty string if no name is available.
7272
*/
7373
default String getName() {
74-
final URI uri = getURI();
75-
return uri == null ? "" : uri.toString();
74+
return defaultName();
7675
}
7776

77+
/**
78+
* Gets the default name used when no explicit name is assigned.
79+
* <p>
80+
* Note: this is mostly intended for debugging, since most kinds of
81+
* {@code Location} will assign some non-default name. But in cases where that
82+
* does not occur, this value can be useful to detect the situation.
83+
* </p>
84+
*
85+
* @return The default name string.
86+
*/
87+
default String defaultName() {
88+
return "Location.defaultName";
89+
}
7890
}

0 commit comments

Comments
 (0)