This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tic(name: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass extends Metrics { | |
def myMethod():Unit = { | |
timed[T](“MyClass.MyMethod”) { | |
// Execute whatever code your method needs here. | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Metrics { | |
def timed[T](name: String)(f: => T):T | |
def succeeded(name: String) | |
def failed(name: String) | |
def tic(name: String) | |
def measured(name: String, value: Long) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Kilograms(value: Double) extends AnyVal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit def kilogramsToDouble(kilos: Kilograms): Double = kilos.value | |
implicit def doubleToKilograms(value: Double): Kilograms = Kilograms(value) | |
implicit def poundsToDouble(pounds: Pounds): Double = pounds.value | |
implicit def doubleToPounds(value: Double): Pounds = Pounds(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit def kilogramsToPounds(kilos: Kilograms): Pounds | |
implicit def poundsToKilograms(pounds: Pounds): Kilograms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def kilogramsToPounds(kilos: Kilograms): Pounds = kilos * 2.20462 | |
def poundsToKilograms(pounds: Pounds): Kilograms = pounds / 2.20462 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Kilograms(value: Double) | |
case class Pounds(value: Double) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class EmailAddress(value: String) { | |
def localPart(): String = … | |
def domain(): String = ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class EmailAddress(value: String) { | |
// Execute validation logic | |
} |