aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuicommon/synchronization/utils/FakeIdGen.scala
diff options
context:
space:
mode:
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)
+ }
+
+}