Skip to content

Commit

Permalink
Added Java API and discoverable factory methods for Offset akka#21788
Browse files Browse the repository at this point in the history
  • Loading branch information
johanandren authored Nov 7, 2016
1 parent 5eed5d7 commit 519064f
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ package akka.persistence.query

import java.util.UUID

object Offset {

// factories to aid discoverability
def noOffset: Offset = NoOffset
def sequence(value: Long): Offset = Sequence(value)
def timeBasedUUID(uuid: UUID): Offset = TimeBasedUUID(uuid)

}

trait Offset

final case class Sequence(val value: Long) extends Offset with Ordered[Sequence] {
Expand All @@ -20,4 +29,9 @@ final case class TimeBasedUUID(val value: UUID) extends Offset with Ordered[Time
override def compare(other: TimeBasedUUID): Int = value.compareTo(other.value)
}

final case object NoOffset extends Offset
final case object NoOffset extends Offset {
/**
* Java API:
*/
def getInstance: Offset = this
}

0 comments on commit 519064f

Please sign in to comment.