getPathDepth static method
Gets the depth level of a path (number of dots + 1) Examples:
- "1" returns 1 (root level)
- "1.1" returns 2 (first child level)
- "1.1.1" returns 3 (grandchild level)
Implementation
static int getPathDepth(String path) {
return path.split('.').length;
}