Interface PropertyPath
- All Known Implementing Classes:
ConfigPath
public interface PropertyPath
Represents an immutable path through a property tree.
Paths are sequences of keys that navigate from the root to a specific node. Supports both string keys (for maps) and integer indices (for lists).
This interface provides a generic abstraction for property paths that can be used across the framework for validation, configuration, and other purposes.
-
Method Summary
Modifier and TypeMethodDescription@NotNull StringasString()Converts the path to a dot-separated string.@NotNull PropertyPathCreates a child path by appending a segment.@NotNull Object[]elements()Returns the path elements.booleanisEmpty()Checks if this path is empty (root path).@Nullable Objectlast()Returns the last element of the path.static @NotNull PropertyPathCreates a path from the given elements.@NotNull PropertyPathparent()Returns the parent path.static @NotNull PropertyPathParses a dot-separated path string.static @NotNull PropertyPathroot()Returns the root path (empty path).intsize()Returns the number of elements in this path.
-
Method Details
-
root
Returns the root path (empty path).- Returns:
- the root path
-
of
Creates a path from the given elements.- Parameters:
elements- the path elements (strings or integers)- Returns:
- a new path
-
parse
Parses a dot-separated path string.Example: "database.connection.host" becomes ["database", "connection", "host"]
- Parameters:
dotPath- the dot-separated path- Returns:
- a new path
-
child
Creates a child path by appending a segment.- Parameters:
segment- the segment to append (String or Integer)- Returns:
- a new path with the segment appended
-
parent
Returns the parent path.- Returns:
- the parent path, or root if this is already root
-
elements
Returns the path elements.- Returns:
- a copy of the elements array
-
size
int size()Returns the number of elements in this path.- Returns:
- the path length
-
isEmpty
boolean isEmpty()Checks if this path is empty (root path).- Returns:
- true if this is the root path
-
last
Returns the last element of the path.- Returns:
- the last element, or null if empty
-
asString
Converts the path to a dot-separated string.- Returns:
- the path as a string
-