matches method

  1. @override
bool matches(
  1. XMLNode node
)
override

Returns true if the node matches the description provided by this Handler.

Implementation

@override
bool matches(XMLNode node) {
  var matches = ['iq', 'message', 'presence'].contains(node.tag);
  if (stanzaTag != null) {
    matches &= node.tag == stanzaTag;
  }
  if (xmlns != null) {
    matches &= node.xmlns == xmlns;
  }

  if (tagName != null) {
    final firstTag = node.firstTag(tagName!, xmlns: tagXmlns);
    matches &= firstTag != null;

    if (tagXmlns != null) {
      matches &= firstTag?.xmlns == tagXmlns;
    }
  } else if (tagXmlns != null) {
    matches &= node.children.firstWhereOrNull(
          (XMLNode node_) => node_.attributes['xmlns'] == tagXmlns,
        ) !=
        null;
  }

  return matches;
}