Skip to content

Commit 102329f

Browse files
committed
MenuPath: add option to trim, or not, as desired
1 parent 1215dd8 commit 102329f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/org/scijava/MenuPath.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,20 @@ public MenuPath(final String path) {
7474
* the specified separator.
7575
*/
7676
public MenuPath(final String path, final String separator) {
77+
this(path, separator, true);
78+
}
79+
80+
/**
81+
* Creates a menu path with entries parsed from the given string, splitting on
82+
* the specified separator, and trimming whitespace if indicated.
83+
*/
84+
public MenuPath(final String path, final String separator,
85+
final boolean trim)
86+
{
7787
if (path != null && !path.isEmpty()) {
7888
final String[] tokens = path.split(separator);
7989
for (final String token : tokens) {
80-
add(new MenuEntry(token.trim()));
90+
add(new MenuEntry(trim ? token.trim() : token));
8191
}
8292
}
8393
}

0 commit comments

Comments
 (0)