Added 'or' method to Versioned.
Signed-off-by: Jonas Bonér <jonas@jonasboner.com>
This commit is contained in:
parent
b1f3107dd7
commit
607eac90e3
1 changed files with 9 additions and 0 deletions
|
|
@ -13,12 +13,21 @@ class VectorClockException(message: String) extends AkkaException(message)
|
|||
*/
|
||||
trait Versioned {
|
||||
def version: VectorClock
|
||||
|
||||
/**
|
||||
* Returns the Versioned that have the latest version.
|
||||
*/
|
||||
def or(other: Versioned): Versioned = Versioned.latestVersionOf(this, other)
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility methods for comparing Versioned instances.
|
||||
*/
|
||||
object Versioned {
|
||||
|
||||
/**
|
||||
* Returns the Versioned that have the latest version.
|
||||
*/
|
||||
def latestVersionOf[T <: Versioned](versioned1: T, versioned2: T): T = {
|
||||
(versioned1.version compare versioned2.version) match {
|
||||
case VectorClock.Before ⇒ versioned2 // version 1 is BEFORE (older), use version 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue