All Downloads are FREE. Search and download functionalities are using the official Maven repository.

play.api.libs.json.scalacheck.Depth.scala Maven / Gradle / Ivy

package play.api.libs.json.scalacheck

import scala.language.implicitConversions

class Depth private[Depth] (val depth: Int) extends AnyVal with Counted {
  override protected def throwOnNegative(): Nothing = throw new IllegalArgumentException("Depth cannot be negative")
  @inline override def count: Int = depth
  def -(that: Depth) = Depth(this.depth - that.depth)
  def +(that: Depth) = new Depth(this.depth + that.depth)  // no need to validate
}

object Depth extends (Int => Depth) {

  implicit def fromInt(int: Int): Depth = Depth(int)

  implicit def toInt(depth: Depth): Int = depth.depth

  override def apply(depth: Int): Depth = {
    val d = new Depth(depth)
    d.validate()
    d
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy