Skip to content

Commit

Permalink
add default implementation to build a group path like Paths.get(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
axtimwalde committed Sep 17, 2020
1 parent 331e0ba commit 2fd6ef7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/org/janelia/saalfeldlab/n5/N5Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,29 @@ public default String getGroupSeparator() {

return "/";
}

/**
* Creates a group path by concatenating all nodes with the node separator
* defined by {@link #getGroupSeparator()}. The string will not have a
* leading or trailing node separator symbol.
*
* @param nodes
* @return
*/
public default String groupPath(final String... nodes) {

if (nodes == null || nodes.length == 0)
return "";

final String groupSeparator = getGroupSeparator();
final StringBuilder builder = new StringBuilder(nodes[0]);

for (int i = 1; i < nodes.length; ++i) {

builder.append(groupSeparator);
builder.append(nodes[i]);
}

return builder.toString();
}
}

0 comments on commit 2fd6ef7

Please sign in to comment.