Class StructNodeFactory


  • public final class StructNodeFactory
    extends java.lang.Object
    Helper 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 custom UpdateListener implementations.

    In contrast to comments parser model, structural model (snakeyaml's) use exact parsed values and ignores all comments.

    Since:
    18.08.2021
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static StructNode createListObject​(StructNode root, int padding, int lineNum, StructNode... props)
      Creates list item node for object.
      static StructNode createListValue​(StructNode root, int padding, int lineNum, java.lang.String value)
      Creates scalar list value.
      static StructNode createProperty​(StructNode 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • createProperty

        public static StructNode createProperty​(StructNode 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.
        Parameters:
        root - root node (may be null)
        padding - padding
        lineNum - target line number
        key - property name (may be null)
        value - property value (may be null for subtree root)
        Returns:
        created node
      • createListObject

        public static StructNode createListObject​(StructNode root,
                                                  int padding,
                                                  int lineNum,
                                                  StructNode... props)
        Creates list item node for object. Grouping node is required to preserve object structure.
        Parameters:
        root - root node (may be null)
        padding - padding
        lineNum - target dash line number
        props - list item object properties (each could be subtree)
        Returns:
        created node
      • createListValue

        public static StructNode createListValue​(StructNode root,
                                                 int padding,
                                                 int lineNum,
                                                 java.lang.String value)
        Creates scalar list value.
        Parameters:
        root - root node (may be null)
        padding - padding
        lineNum - target dash line number
        value - property value lines (may be null)
        Returns:
        created node