Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Does away with this pesky compiler warning in scala 2.10.0 "`withFilter' method does not yet exist on org.json4s.JValue, using `filter' method instead"
import org.json4s.JValue
implicit class LiftJValueWithFilter(self: JValue)
extends JValueWithFilter(self, _ => true)
class JValueWithFilter(self: JValue, p: JValue => Boolean) {
def map(f: JValue => T): List[T] =
self.filter(p).map(f)
def flatMap(f: JValue => List[T]): List[T] =
self.filter(p).flatMap(f)
def foreach(f: JValue => Unit): Unit =
self.filter(p).foreach(f)
def withFilter(q: JValue => Boolean): JValueWithFilter =
new JValueWithFilter(self, x => p(x) && q(x))
}
@vpatryshev
Copy link

vpatryshev commented Oct 20, 2015

Thanks a lot! Obvious, but so useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment