Permalink
Browse files

Delta support in BaseEdge

  • Loading branch information...
1 parent f87ad81 commit 3d571d82adb4506381b5561cf89c1b0b4170e7ea @michaelochurch michaelochurch committed Mar 31, 2012
Showing with 17 additions and 3 deletions.
  1. +17 −3 src/main/scala/Edge.scala
@@ -1,13 +1,27 @@
import Name.{T => Name}
-abstract class Edge {
+trait Edge {
+ type T
+ type Delta
+
val id : Name
val source : Name
val dest : Name
+
+ def +(delta:Delta):T
}
-class BaseEdge(val payload: Payload, val source:Name, val dest:Name) extends Edge {
- val id = Name.make()
+class BaseEdge private (val payload: Payload, val source:Name, val dest:Name, val id:Name) extends Edge {
+ type T = BaseEdge
+ type Delta = PayloadDelta
+
+ def this(payload:Payload, source:Name, dest:Name) = {
+ this(payload, source, dest, Name.make())
+ }
+
+ def +(delta:Delta):BaseEdge = {
+ new BaseEdge(payload + delta, source, dest, id)
+ }
private def tuple() = {
(id, source, dest, payload)

0 comments on commit 3d571d8

Please sign in to comment.