All Downloads are FREE. Search and download functionalities are using the official Maven repository.

advxml.syntax.XmlNormalizerSyntax.scala Maven / Gradle / Ivy

There is a newer version: 2.3.0-NEW-BUILD
Show newest version
package advxml.syntax

import advxml.core.XmlNormalizer
import org.scalactic.Equality

import scala.util.Try
import scala.xml.NodeSeq

private[syntax] trait XmlNormalizerSyntax {

  implicit def streamlinedXmlNormalizedEquality[T <: NodeSeq]: Equality[T] =
    (a: T, b: Any) => Try(XmlNormalizer.normalizedEquals(a, b.asInstanceOf[NodeSeq])).getOrElse(false)

  implicit class NodeSeqNormalizationAndEqualityOps(ns: NodeSeq) {

    def normalize: NodeSeq =
      XmlNormalizer.normalize(ns)

    def normalizedEquals(ns2: NodeSeq): Boolean =
      XmlNormalizer.normalizedEquals(ns, ns2)

    def |==|(ns2: NodeSeq): Boolean =
      XmlNormalizer.normalizedEquals(ns, ns2)

    def |!=|(ns2: NodeSeq): Boolean =
      !XmlNormalizer.normalizedEquals(ns, ns2)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy