From 97e75b8d777c6661461493b28d91559fabf237ba Mon Sep 17 00:00:00 2001 From: Stewart Stewart Date: Wed, 10 May 2017 14:51:43 -0400 Subject: try to match uuid first in id PathMatcher --- src/main/scala/xyz/driver/core/json.scala | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/main/scala/xyz') diff --git a/src/main/scala/xyz/driver/core/json.scala b/src/main/scala/xyz/driver/core/json.scala index 67bf8e4..6f772f3 100644 --- a/src/main/scala/xyz/driver/core/json.scala +++ b/src/main/scala/xyz/driver/core/json.scala @@ -18,16 +18,11 @@ import xyz.driver.core.time.Time object json { import DefaultJsonProtocol._ - def IdInPath[T]: PathMatcher1[Id[T]] = new PathMatcher1[Id[T]] { - def apply(path: Path) = path match { - case Path.Segment(segment, tail) => Matched(tail, Tuple1(Id[T](segment))) - case _ => Unmatched - } - } + private def UuidInPath[T]: PathMatcher1[Id[T]] = PathMatchers.JavaUUID.map((id: UUID) => Id[T](id.toString)) - def UuidInPath[T]: PathMatcher1[Id[T]] = new PathMatcher1[Id[T]] { + def IdInPath[T]: PathMatcher1[Id[T]] = UuidInPath[T] | new PathMatcher1[Id[T]] { def apply(path: Path) = path match { - case Path.Segment(segment, tail) => Matched(tail, Tuple1(Id[T](UUID.fromString(segment).toString))) + case Path.Segment(segment, tail) => Matched(tail, Tuple1(Id[T](segment))) case _ => Unmatched } } -- cgit v1.2.3