Package org.onosproject.store.service
Class DocumentPath
- java.lang.Object
-
- org.onosproject.store.service.DocumentPath
-
- All Implemented Interfaces:
java.lang.Comparable<DocumentPath>
public class DocumentPath extends java.lang.Object implements java.lang.Comparable<DocumentPath>
Unique key for nodes in theDocumentTree
.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_SEPARATOR
Default path separator.static java.lang.String
DEFAULT_SEPARATOR_RE
Default path separator regex.static DocumentPath
ROOT
Root document tree path.
-
Constructor Summary
Constructors Constructor Description DocumentPath(java.lang.String nodeName, DocumentPath parentPath)
Constructs a new document path.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DocumentPath
append(java.util.List<java.lang.String> childElms)
Creates a new DocumentPath element appendingchildElm
to this path.DocumentPath
childPath()
Returns the relative path to the given node.int
compareTo(DocumentPath that)
boolean
equals(java.lang.Object obj)
static DocumentPath
from(java.lang.String path)
Creates a newDocumentPath
from a period delimited path string.static DocumentPath
from(java.lang.String... elements)
Creates a newDocumentPath
from a list of path elements.static DocumentPath
from(java.util.List<java.lang.String> elements)
Creates a newDocumentPath
from a list of path elements.static DocumentPath
from(java.util.List<java.lang.String> elements, java.lang.String child)
Creates a newDocumentPath
from a list of path elements.static DocumentPath
from(java.util.List<java.lang.String> elements, java.lang.String... childElms)
Creates a newDocumentPath
from a list of path elements.int
hashCode()
boolean
isAncestorOf(DocumentPath other)
Returns if the specified path belongs to a direct ancestor of the node pointed at by this path.boolean
isDescendentOf(DocumentPath other)
Returns if the specified path is belongs to a subtree rooted this path.static DocumentPath
leastCommonAncestor(java.util.Collection<DocumentPath> paths)
Returns the path that points to the least common ancestor of the specified collection of paths.DocumentPath
parent()
Returns a path for the parent of this node.java.util.List<java.lang.String>
pathElements()
Returns the list of path elements representing this path in correct order.java.lang.String
toString()
-
-
-
Field Detail
-
DEFAULT_SEPARATOR
public static final java.lang.String DEFAULT_SEPARATOR
Default path separator.- See Also:
- Constant Field Values
-
DEFAULT_SEPARATOR_RE
public static final java.lang.String DEFAULT_SEPARATOR_RE
Default path separator regex.- See Also:
- Constant Field Values
-
ROOT
public static final DocumentPath ROOT
Root document tree path.
-
-
Constructor Detail
-
DocumentPath
public DocumentPath(java.lang.String nodeName, DocumentPath parentPath)
Constructs a new document path.New paths must contain at least one name and string names MUST NOT contain any path separator characters. If one field is
null
that field will be ignored.- Parameters:
nodeName
- the name of the last level of this pathparentPath
- the path representing the parent leading up to this node, in the case of the root this should benull
- Throws:
IllegalDocumentNameException
- if both parameters are null or name contains an illegal character ('.')
-
-
Method Detail
-
from
public static DocumentPath from(java.lang.String path)
Creates a newDocumentPath
from a period delimited path string.- Parameters:
path
- path string- Returns:
DocumentPath
instance
-
from
public static DocumentPath from(java.lang.String... elements)
Creates a newDocumentPath
from a list of path elements.- Parameters:
elements
- path elements- Returns:
DocumentPath
instance
-
from
public static DocumentPath from(java.util.List<java.lang.String> elements)
Creates a newDocumentPath
from a list of path elements.- Parameters:
elements
- path elements- Returns:
DocumentPath
instance
-
from
public static DocumentPath from(java.util.List<java.lang.String> elements, java.lang.String child)
Creates a newDocumentPath
from a list of path elements.- Parameters:
elements
- path elementschild
- child element- Returns:
DocumentPath
instance
-
from
public static DocumentPath from(java.util.List<java.lang.String> elements, java.lang.String... childElms)
Creates a newDocumentPath
from a list of path elements.- Parameters:
elements
- path elementschildElms
- child element- Returns:
DocumentPath
instance
-
append
public DocumentPath append(java.util.List<java.lang.String> childElms)
Creates a new DocumentPath element appendingchildElm
to this path.- Parameters:
childElms
- to append- Returns:
- this + childElm
-
childPath
public DocumentPath childPath()
Returns the relative path to the given node.- Returns:
- relative path to the given node.
-
parent
public DocumentPath parent()
Returns a path for the parent of this node.- Returns:
- parent node path. If this path is for the root, returns
null
.
-
pathElements
public java.util.List<java.lang.String> pathElements()
Returns the list of path elements representing this path in correct order.- Returns:
- a list of elements that make up this path
-
isAncestorOf
public boolean isAncestorOf(DocumentPath other)
Returns if the specified path belongs to a direct ancestor of the node pointed at by this path.Example:
root.a
is a direct ancestor ofr.a.b.c
; whiler.a.x
is not.- Parameters:
other
- other path- Returns:
true
is yes;false
otherwise.
-
isDescendentOf
public boolean isDescendentOf(DocumentPath other)
Returns if the specified path is belongs to a subtree rooted this path.Example:
root.a.b
androot.a.b.c.d.e
are descendants ofr.a.b
; whiler.a.x.c
is not.- Parameters:
other
- other path- Returns:
true
is yes;false
otherwise.
-
leastCommonAncestor
public static DocumentPath leastCommonAncestor(java.util.Collection<DocumentPath> paths)
Returns the path that points to the least common ancestor of the specified collection of paths.- Parameters:
paths
- collection of path- Returns:
- path to least common ancestor or null if there is nothing in common
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
compareTo
public int compareTo(DocumentPath that)
- Specified by:
compareTo
in interfacejava.lang.Comparable<DocumentPath>
-
-