Class CmtNodeFactory
- java.lang.Object
-
- ru.vyarus.yaml.updater.parse.comments.model.CmtNodeFactory
-
public final class CmtNodeFactory extends java.lang.ObjectHelper factory class for creating correct node objects. It is not used by main code and exists only for tests and to simplify manual tree modifications in customUpdateListenerimplementations.It is important to keep in mind that comments parser does not care of exact value, but care how many lines it takes (it is important to write node back exactly as-is). Value is everything after semicolon.
Like value, comment is also stored as-is, from line start. Comment is everything above node before previous node. Comment-only node (without key or value) may go last on any tree level to represent trailing comment (but, usually, it's only useful for root node to represent comment at the end of file because in other cases all comment lines would simply be assigned to the following node (no matter what level - in some cases impossible to track)).
- Since:
- 18.08.2021
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CmtNodecreateListObject(CmtNode root, int padding, int lineNum, CmtNode... props)Creates list item node for object.static CmtNodecreateListValue(CmtNode root, int padding, int lineNum, java.lang.String... value)Creates scalar list value.static CmtNodecreateProperty(CmtNode root, int padding, int lineNum, java.lang.String key, java.lang.String... value)Could be used to create any node type: with both key and value it would be property, without value - subtree root and without both key and value - stub for virtualized list item.
-
-
-
Method Detail
-
createProperty
public static CmtNode createProperty(CmtNode root, int padding, int lineNum, java.lang.String key, java.lang.String... value)
Could be used to create any node type: with both key and value it would be property, without value - subtree root and without both key and value - stub for virtualized list item.PAY ATTENTION: value include EVERYTHING after colon! (including separating space)
- Parameters:
root- root node (may be null)padding- paddinglineNum- target line numberkey- property name (may be null)value- property value lines (may be null for subtree root)- Returns:
- created node
-
createListObject
public static CmtNode createListObject(CmtNode root, int padding, int lineNum, CmtNode... props)
Creates list item node for object. Grouping node is required to preserve object structure.- Parameters:
root- root node (may be null)padding- paddinglineNum- target dash line numberprops- list item object properties (each could be subtree)- Returns:
- created node
-
createListValue
public static CmtNode createListValue(CmtNode root, int padding, int lineNum, java.lang.String... value)
Creates scalar list value.PAY ATTENTION: value include EVERYTHING after colon! (including separating space)
- Parameters:
root- root node (may be null)padding- paddinglineNum- target dash line numbervalue- property value lines (may be null)- Returns:
- created node
-
-