diff options
author | vlad <vlad@driver.xyz> | 2017-06-13 16:15:07 -0700 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-06-13 16:15:07 -0700 |
commit | 91a4120b4253dc4a1e9552ec39fcb25c303a21e1 (patch) | |
tree | 9173797ed8e3d780f98ac8d0f85507eeb10c8016 /src/main/scala/xyz/driver/pdsuicommon/db/Sorting.scala | |
parent | cd1b635b2ae90d9ac2d8b1779183a1fbd8c5fd5c (diff) | |
download | rest-query-d55b202095f733138d5583966984c22e102c08f8.tar.gz rest-query-d55b202095f733138d5583966984c22e102c08f8.tar.bz2 rest-query-d55b202095f733138d5583966984c22e102c08f8.zip |
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuicommon/db/Sorting.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuicommon/db/Sorting.scala | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/main/scala/xyz/driver/pdsuicommon/db/Sorting.scala b/src/main/scala/xyz/driver/pdsuicommon/db/Sorting.scala index 4b2427c..b796b83 100644 --- a/src/main/scala/xyz/driver/pdsuicommon/db/Sorting.scala +++ b/src/main/scala/xyz/driver/pdsuicommon/db/Sorting.scala @@ -7,7 +7,7 @@ import scala.collection.generic.CanBuildFrom sealed trait SortingOrder object SortingOrder { - case object Ascending extends SortingOrder + case object Ascending extends SortingOrder case object Descending extends SortingOrder } @@ -34,25 +34,24 @@ object Sorting { def isEmpty(input: Sorting): Boolean = { input match { case Sequential(Seq()) => true - case _ => false + case _ => false } } def filter(sorting: Sorting, p: Dimension => Boolean): Seq[Dimension] = sorting match { case x: Dimension if p(x) => Seq(x) - case x: Dimension => Seq.empty - case Sequential(xs) => xs.filter(p) + case x: Dimension => Seq.empty + case Sequential(xs) => xs.filter(p) } - def collect[B, That](sorting: Sorting) - (f: PartialFunction[Dimension, B]) - (implicit bf: CanBuildFrom[Seq[Dimension], B, That]): That = sorting match { + def collect[B, That](sorting: Sorting)(f: PartialFunction[Dimension, B])( + implicit bf: CanBuildFrom[Seq[Dimension], B, That]): That = sorting match { case x: Dimension if f.isDefinedAt(x) => val r = bf.apply() r += f(x) r.result() - case x: Dimension => bf.apply().result() + case x: Dimension => bf.apply().result() case Sequential(xs) => xs.collect(f) } |