Class FilterTagChildrenVisitor<T>

java.lang.Object
org.openrewrite.TreeVisitor<Xml,P>
org.openrewrite.xml.XmlVisitor<T>
org.openrewrite.xml.FilterTagChildrenVisitor<T>

public class FilterTagChildrenVisitor<T> extends XmlVisitor<T>
Filter the children to only those matching the supplied predicate.
  • Field Details

  • Constructor Details

    • FilterTagChildrenVisitor

      public FilterTagChildrenVisitor()
  • Method Details

    • visitTag

      public Xml visitTag(Xml.Tag tag, T ctx)
      Overrides:
      visitTag in class XmlVisitor<T>
    • filterChildren

      public static Xml.Tag filterChildren(Xml.Tag parent, Predicate<Content> childTest)
      Filter the children of a tag to only those that match the supplied predicate.
      Parameters:
      parent - the tag whose direct child elements are to be filtered by 'childTest'
      childTest - the predicate used to evaluate the direct child elements of 'parent'.
      Returns:
      'parent' with its children that matched 'childTest'
    • filterChildren

      public static Xml.Tag filterChildren(Xml.Tag parentScope, Xml.Tag parent, Predicate<Content> childTest)
      Filter the children of a tag to only those that match the supplied predicate.
      Parameters:
      parentScope - a tag which contains 'parent' as a direct or transitive child element.
      parent - the tag whose direct child elements are to be filtered by 'childTest'
      childTest - the predicate used to evaluate the direct child elements of 'parent'.
      Returns:
      'parentScope` which somewhere contains 'parent' with its children that matched 'childTest'
    • filterTagChildren

      public static Xml.Tag filterTagChildren(Xml.Tag parent, Predicate<Xml.Tag> childTest)
      Filter the children of a tag to only those that match the supplied predicate. Non-tag children, such as comments, are untouched.
      Parameters:
      parent - the tag whose direct child elements are to be filtered by 'childTest'
      childTest - the predicate used to evaluate the direct child elements of 'parent'.
      Returns:
      'parent' with its children that matched 'childTest'
    • filterTagChildren

      public static Xml.Tag filterTagChildren(Xml.Tag parentScope, Xml.Tag parent, Predicate<Xml.Tag> childTest)
      Filter the children of a tag to only those that match the supplied predicate. Non-tag children, such as comments, are untouched.
      Parameters:
      parentScope - a tag which contains 'parent' as a direct or transitive child element.
      parent - the tag whose direct child elements are to be filtered by 'childTest'
      childTest - the predicate used to evaluate the direct child elements of 'parent'.
      Returns:
      'parentScope` which somewhere contains 'parent' with its children that matched 'childTest'