Skip to content

Commit 287d823

Browse files
committed
Location: add getName() method
The name returned is meant as an analogue to a file name and might be used for meta-data purposes. Signed-off-by: Curtis Rueden <ctrueden@wisc.edu>
1 parent 26df831 commit 287d823

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* </p>
4747
*
4848
* @author Curtis Rueden
49+
* @author Gabriel Einsdorf
4950
*/
5051
public interface Location {
5152

@@ -57,4 +58,13 @@ default URI getURI() {
5758
return null;
5859
}
5960

61+
/**
62+
* Gets the name of the object addressed by this location, or an empty string
63+
* if it has no name.
64+
*/
65+
default String getName() {
66+
final URI uri = getURI();
67+
return uri == null ? "" : uri.toString();
68+
}
69+
6070
}

0 commit comments

Comments
 (0)