Class XmlNode.Builder

java.lang.Object
org.apache.maven.api.xml.XmlNode.Builder
Enclosing interface:
XmlNode

public static class XmlNode.Builder extends Object
Builder class for creating XmlNode instances.

This builder provides a fluent API for setting the various properties of an XML node. All properties are optional except for the node name, which must be set before calling build().

Since:
4.0.0
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • name

      public XmlNode.Builder name(String name)
      Sets the name of the XML node.

      This is the only required property that must be set before calling build().

      Parameters:
      name - the name of the XML node
      Returns:
      this builder instance
      Throws:
      NullPointerException - if name is null
    • value

      public XmlNode.Builder value(String value)
      Sets the text content of the XML node.
      Parameters:
      value - the text content of the XML node
      Returns:
      this builder instance
    • namespaceUri

      public XmlNode.Builder namespaceUri(String namespaceUri)
      Sets the namespace URI of the XML node.
      Parameters:
      namespaceUri - the namespace URI of the XML node
      Returns:
      this builder instance
    • prefix

      public XmlNode.Builder prefix(String prefix)
      Sets the namespace prefix of the XML node.
      Parameters:
      prefix - the namespace prefix of the XML node
      Returns:
      this builder instance
    • attributes

      public XmlNode.Builder attributes(Map<String,String> attributes)
      Sets the attributes of the XML node.

      The provided map will be copied to ensure immutability.

      Parameters:
      attributes - the map of attribute names to values
      Returns:
      this builder instance
    • children

      public XmlNode.Builder children(List<XmlNode> children)
      Sets the child nodes of the XML node.

      The provided list will be copied to ensure immutability.

      Parameters:
      children - the list of child nodes
      Returns:
      this builder instance
    • inputLocation

      public XmlNode.Builder inputLocation(Object inputLocation)
      Sets the input location information for the XML node.

      This is typically used for error reporting and debugging purposes.

      Parameters:
      inputLocation - the input location object
      Returns:
      this builder instance
    • build

      public XmlNode build()
      Builds a new XmlNode instance with the current builder settings.
      Returns:
      a new immutable XmlNode instance
      Throws:
      NullPointerException - if name has not been set