Package org.openrewrite.xml
Class AddOrUpdateChild<P>
java.lang.Object
org.openrewrite.TreeVisitor<org.openrewrite.xml.tree.Xml,P>
org.openrewrite.xml.XmlVisitor<P>
org.openrewrite.xml.AddOrUpdateChild<P>
public class AddOrUpdateChild<P>
extends org.openrewrite.xml.XmlVisitor<P>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.openrewrite.xml.tree.Xml.TagaddOrUpdateChild(org.openrewrite.xml.tree.Xml.Tag parent, org.openrewrite.xml.tree.Xml.Tag child, org.openrewrite.Cursor parentCursor) Add the specified child tag to the parent tag's children.static org.openrewrite.xml.tree.Xml.TagaddOrUpdateChild(org.openrewrite.xml.tree.Xml.Tag parentScope, org.openrewrite.xml.tree.Xml.Tag parent, org.openrewrite.xml.tree.Xml.Tag child, org.openrewrite.Cursor parentCursor) Add the specified child tag to the parent tag's children.org.openrewrite.xml.tree.XmlMethods inherited from class org.openrewrite.xml.XmlVisitor
autoFormat, autoFormat, autoFormat, getLanguage, isAcceptable, maybeAutoFormat, maybeAutoFormat, maybeAutoFormat, visitAttribute, visitAttributeValue, visitCharData, visitComment, visitDocTypeDecl, visitDocTypeDeclExternalSubsets, visitDocument, visitElement, visitIdent, visitJspComment, visitJspDeclaration, visitJspDirective, visitJspExpression, visitJspScriptlet, visitProcessingInstruction, visitProlog, visitTagClosing, visitXmlDeclMethods inherited from class org.openrewrite.TreeVisitor
adapt, collect, collect, defaultValue, doAfterVisit, getAfterVisit, getCursor, isAdaptableTo, noop, postVisit, preVisit, reduce, reduce, reduce, setCursor, stopAfterPreVisit, updateCursor, visit, visit, visit, visitAndCast, visitAndCast, visitMarker, visitMarkers, visitNonNull, visitNonNull, visitorTreeType
-
Constructor Details
-
AddOrUpdateChild
public AddOrUpdateChild()
-
-
Method Details
-
visitTag
- Overrides:
visitTagin classorg.openrewrite.xml.XmlVisitor<P>
-
addOrUpdateChild
public static org.openrewrite.xml.tree.Xml.Tag addOrUpdateChild(org.openrewrite.xml.tree.Xml.Tag parent, org.openrewrite.xml.tree.Xml.Tag child, org.openrewrite.Cursor parentCursor) Add the specified child tag to the parent tag's children. If a tag with the same name as the new child tag already exists within the parent tag's children it is replaced. If no tag with the same name exists, the child tag is added.- Parameters:
parent- the tag to add 'child' to.child- the tag to add to the children of 'parent'.parentCursor- A cursor pointing one level above 'parent'. Determines the final indentation of 'child'.- Returns:
- 'parent' with 'child' among its direct child tags.
-
addOrUpdateChild
public static org.openrewrite.xml.tree.Xml.Tag addOrUpdateChild(org.openrewrite.xml.tree.Xml.Tag parentScope, org.openrewrite.xml.tree.Xml.Tag parent, org.openrewrite.xml.tree.Xml.Tag child, org.openrewrite.Cursor parentCursor) Add the specified child tag to the parent tag's children. If a tag with the same name as the new child tag already exists within the parent tag's children it is replaced. If no tag with the same name exists, the child tag is added.- Parameters:
parentScope- a tag which contains 'parent' as a direct or transitive child element.parent- the tag to add 'child' to.child- the tag to add to the children of 'parent'.parentCursor- A cursor pointing one level above 'parent'. Determines the final indentation of 'child'.- Returns:
- 'parentScope' which somewhere contains 'parent' with 'child' among its direct child tags.
-