Class ServicePath
java.lang.Object
com.github.cafapi.common.util.naming.ServicePath
Simple object to store the service path, expected to be in the form /group/subgroup/id. Internally this is represented by a
javax.naming.Name object. Any leading or terminating forward-slashes are removed upon creation.
Valid path: a/b/c Valid path: /a/b/c/ (leading and terminating slashes will be removed) Invalid path: /a/b//c/ (empty naming groups are
not allowed) Invalid path: /a (no group)
-
Constructor Details
-
ServicePath
Create a new ServicePath from a String.- Parameters:
path
- the String to create the ServicePath from- Throws:
InvalidNameException
- if there are invalid characters, empty groups, or less than 2 components
-
-
Method Details
-
getRoot
Return the root of the service path, ie. the first group the service is a part of. In the service path "/a/b/c", this will be "a".- Returns:
- the root of the service path
-
getLeaf
Return the leaf or "tip" of the service path, ie. the final part of the service name. In the service path "/a/b/c", this will be "c".- Returns:
- the leaf of the service path
-
getGroup
Return the immediate group of the service, ie. the node above the leaf. In the service path "/a/b/c", this will be "b".- Returns:
- the immediate group of the service
-
getPath
- Returns:
- the full service path
-
toString
-
iterator
Each iteration is the next element of the service path. -
groupIterator
- Returns:
- an iterator that only iterates over the groups and subgroups of the service
-
descendingPathIterator
- Returns:
- an Iterator where each element is the entire service path up to the (decrementing) index
-