def fromJava()

in util-core/src/main/scala/com/twitter/util/Duration.scala [45:103]


  def fromJava(value: java.time.Duration): Duration = fromNanoseconds(value.toNanos)

  // This is needed for Java compatibility.
  override val Zero: Duration = new Duration(0)

  /**
   * Duration `Top` is greater than any other duration, except for
   * itself. `Top`'s complement is `Bottom`.
   */
  val Top: Duration = new Duration(Long.MaxValue) {
    override def hashCode = System.identityHashCode(this)

    /** Top is equal only to Top and greater than every finite duration */
    override def compare(that: Duration) =
      if (that eq Undefined) -1
      else if (that eq Top) 0
      else 1

    override def equals(other: Any) = other match {
      case d: Duration => d eq this
      case _ => false
    }

    override def *(x: Long): Duration =
      if (x == 0) Undefined
      else if (x < 0) Bottom
      else Top

    override def *(x: Double): Duration =
      if (x == 0.0 || java.lang.Double.isNaN(x)) Undefined
      else if (x < 0.0) Bottom
      else Top

    override def /(x: Long): Duration =
      if (x == 0) Undefined
      else if (x < 0) Bottom
      else Top

    override def /(x: Double): Duration =
      if (x == 0.0 || java.lang.Double.isNaN(x)) Undefined
      else if (x < 0.0) Bottom
      else Top

    override def isFinite = false

    override def %(x: Duration) = Undefined
    override def abs = this
    override def fromNow = Time.Top
    override def ago = Time.Bottom
    override def afterEpoch = Time.Top
    override def +(delta: Duration) = delta match {
      case Bottom | Undefined => Undefined
      case _ => this
    }
    override def unary_- = Bottom
    override def toString = "Duration.Top"

    private def writeReplace(): Object = DurationBox.Top()
  }