Skip to content

Commit

Permalink
734: moved package objects to package.scala files
Browse files Browse the repository at this point in the history
  • Loading branch information
patriknw committed Apr 5, 2011
1 parent bb55de4 commit 2214c7f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
20 changes: 0 additions & 20 deletions akka-actor/src/main/scala/akka/util/Duration.scala
Expand Up @@ -317,26 +317,6 @@ class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duration {
override def hashCode = toNanos.asInstanceOf[Int] override def hashCode = toNanos.asInstanceOf[Int]
} }


package object duration {
implicit def intToDurationInt(n: Int) = new DurationInt(n)
implicit def longToDurationLong(n: Long) = new DurationLong(n)
implicit def doubleToDurationDouble(d: Double) = new DurationDouble(d)

implicit def pairIntToDuration(p : (Int, TimeUnit)) = Duration(p._1, p._2)
implicit def pairLongToDuration(p : (Long, TimeUnit)) = Duration(p._1, p._2)
implicit def durationToPair(d : Duration) = (d.length, d.unit)

implicit def intMult(i : Int) = new {
def *(d : Duration) = d * i
}
implicit def longMult(l : Long) = new {
def *(d : Duration) = d * l
}
implicit def doubleMult(f : Double) = new {
def *(d : Duration) = d * f
}
}

class DurationInt(n: Int) { class DurationInt(n: Int) {
def nanoseconds = Duration(n, NANOSECONDS) def nanoseconds = Duration(n, NANOSECONDS)
def nanos = Duration(n, NANOSECONDS) def nanos = Duration(n, NANOSECONDS)
Expand Down
27 changes: 27 additions & 0 deletions akka-actor/src/main/scala/akka/util/package.scala
@@ -0,0 +1,27 @@
/**
* Copyright (C) 2009-2011 Scalable Solutions AB <http://scalablesolutions.se>
*/

package akka.util

import java.util.concurrent.TimeUnit

package object duration {
implicit def intToDurationInt(n: Int) = new DurationInt(n)
implicit def longToDurationLong(n: Long) = new DurationLong(n)
implicit def doubleToDurationDouble(d: Double) = new DurationDouble(d)

implicit def pairIntToDuration(p : (Int, TimeUnit)) = Duration(p._1, p._2)
implicit def pairLongToDuration(p : (Long, TimeUnit)) = Duration(p._1, p._2)
implicit def durationToPair(d : Duration) = (d.length, d.unit)

implicit def intMult(i : Int) = new {
def *(d : Duration) = d * i
}
implicit def longMult(l : Long) = new {
def *(d : Duration) = d * l
}
implicit def doubleMult(f : Double) = new {
def *(d : Duration) = d * f
}
}

0 comments on commit 2214c7f

Please sign in to comment.