aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuicommon/synchronization/utils/FakeIdGen.scala
diff options
context:
space:
mode:
authorKseniya Tomskikh <ktomskih@datamonsters.co>2017-10-03 16:57:48 +0700
committerGitHub <noreply@github.com>2017-10-03 16:57:48 +0700
commit53c149e5de2ab137967ce8068e0e249be3a99422 (patch)
treea87d24b1b5d6489576f00fe446f05b5110d62cc0 /src/main/scala/xyz/driver/pdsuicommon/synchronization/utils/FakeIdGen.scala
parent1913870abec9e31d080f6858d0fc296445852cc6 (diff)
parentd0e3c6f37347142a3ef5eab871dde47ea70af304 (diff)
downloadrest-query-53c149e5de2ab137967ce8068e0e249be3a99422.tar.gz
rest-query-53c149e5de2ab137967ce8068e0e249be3a99422.tar.bz2
rest-query-53c149e5de2ab137967ce8068e0e249be3a99422.zip
Merge pull request #34 from drivergroup/synch-refactor
Common code for synchronizers
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuicommon/synchronization/utils/FakeIdGen.scala')
-rw-r--r--src/main/scala/xyz/driver/pdsuicommon/synchronization/utils/FakeIdGen.scala26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuicommon/synchronization/utils/FakeIdGen.scala b/src/main/scala/xyz/driver/pdsuicommon/synchronization/utils/FakeIdGen.scala
new file mode 100644
index 0000000..196aab1
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuicommon/synchronization/utils/FakeIdGen.scala
@@ -0,0 +1,26 @@
+package xyz.driver.pdsuicommon.synchronization.utils
+
+import xyz.driver.pdsuicommon.synchronization.domain.FakeId
+
+/**
+ * Used to generate a fake id from an entity.
+ * A fake id is used in comparison between entities with different types,
+ * for example, RawTrial and Trial.
+ *
+ * @see FakeId
+ */
+trait FakeIdGen[-T] extends (T => FakeId) {
+
+ def getFor(x: T): FakeId
+
+ override def apply(x: T): FakeId = getFor(x)
+
+}
+
+object FakeIdGen {
+
+ def create[T](f: T => FakeId) = new FakeIdGen[T] {
+ override def getFor(x: T): FakeId = f(x)
+ }
+
+}