com.evolutiongaming.kafka.journal.ExpireAfter.scala Maven / Gradle / Ivy
The newest version!
package com.evolutiongaming.kafka.journal
import cats.Show
import cats.kernel.{Eq, Order}
import com.evolutiongaming.kafka.journal.util.PlayJsonHelper._
import play.api.libs.json.{Reads, Writes}
import scala.concurrent.duration.FiniteDuration
final case class ExpireAfter(value: FiniteDuration) {
override def toString: String = value.toString()
}
object ExpireAfter {
implicit val eqExpireAfter: Eq[ExpireAfter] = Eq.fromUniversalEquals
implicit val showExpireAfter: Show[ExpireAfter] = Show.fromToString
implicit val orderingExpireAfter: Ordering[ExpireAfter] = (a, b) => a.value compare b.value
implicit val orderExpireAfter: Order[ExpireAfter] = Order.fromOrdering
implicit val writesExpireAfter: Writes[ExpireAfter] = Writes.of[FiniteDuration].contramap { _.value }
implicit val readsExpireAfter: Reads[ExpireAfter] = Reads.of[FiniteDuration].map { a => ExpireAfter(a) }
object implicits {
implicit class FiniteDurationOpsExpireAfter(val self: FiniteDuration) extends AnyVal {
def toExpireAfter: ExpireAfter = ExpireAfter(self)
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy