Class OwnedPaths
OperatorFileWriter may change in a config file: the value paths it sets,
inserts or removes, the paths whose comment lines it rewrites, or - only when the file does not exist yet -
the whole file. Everything else in the file is the operator's and must come out of the write byte for byte
as it went in (maintainer decision 2026-10-04, "what code may write, by file type").
A path is a list of whole keys, one element per mapping level; a key containing . is one key. A
value path owns the whole key: its key line, its value, and - when the key is inserted or removed, or its
comment is owned - the comment lines directly above it. An owned comment is either the key's whole comment or,
for a framework comment (OwnedPaths.Builder.frameworkComment(List, int)), only its last lines: the run the
framework identified as its own, so every comment line above that run stays the operator's (#604).
An inserted key under a section left with no value (#620, owned-span rule revision 3, maintainer decision
2026-10-06). When the operator deletes every key of a section, the section key is left on its own line with nothing
after the colon (messages:), which reads as no value at all. A value path inserted below such a line also owns
that one line: the section becomes a mapping that holds exactly the inserted keys. This cannot overwrite operator
content - the line carried no value, its key as written, its comment text and its line terminator are kept (only
whitespace on it may be normalized: before the colon, before the comment, and trailing), and every other line of the
file must still come out byte for byte. OperatorFileWriter decides this from the file at write time; a section
written as an empty value (~, null, {}) is the operator's value and is never owned this way.
Instances are immutable.
- Since:
- 6.3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classCollects owned paths; each path is copied, so later changes to the caller's list do not leak in. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic OwnedPaths.Builderbuilder()Starts a description of owned keys.commentRun(List<String> path) How many of the last comment lines above the key atpaththis write owns in the file as read, when the path was declared withOwnedPaths.Builder.frameworkComment(List, int);nullwhen the whole comment is owned or the path's comment is not owned at all.comments()The paths whose comment lines this write rewrites.booleanWhether this write owns the whole file (allowed only when the file is absent).values()The value paths this write sets, inserts or removes.static OwnedPathsThe whole file, for creating a file that does not exist.
-
Field Details
-
WHOLE_FILE
-
values
-
comments
-
commentRuns
-
wholeFile
private final boolean wholeFile
-
-
Constructor Details
-
OwnedPaths
-
-
Method Details
-
wholeFile
The whole file, for creating a file that does not exist.OperatorFileWriterrefuses this ownership for a file that exists.- Returns:
- the whole-file ownership
-
builder
Starts a description of owned keys.- Returns:
- an empty builder
-
values
The value paths this write sets, inserts or removes.- Returns:
- unmodifiable paths, in declaration order
-
comments
The paths whose comment lines this write rewrites.- Returns:
- unmodifiable paths, in declaration order
-
commentRun
How many of the last comment lines above the key atpaththis write owns in the file as read, when the path was declared withOwnedPaths.Builder.frameworkComment(List, int);nullwhen the whole comment is owned or the path's comment is not owned at all.- Parameters:
path- the key path- Returns:
- the owned run's length in the file, or
null
-
isWholeFile
public boolean isWholeFile()Whether this write owns the whole file (allowed only when the file is absent).- Returns:
- whether the whole file is owned
-