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

zhttp.endpoint.CanExtract.scala Maven / Gradle / Ivy

There is a newer version: 2.0.0-RC11
Show newest version
package zhttp.endpoint

import scala.util.Try

trait CanExtract[+A] {
  def parse(data: String): Option[A]
}
object CanExtract    {
  implicit object IntImpl     extends CanExtract[Int]     {
    override def parse(data: String): Option[Int] = Try(data.toInt).toOption
  }
  implicit object StringImpl  extends CanExtract[String]  {
    override def parse(data: String): Option[String] = Option(data)
  }
  implicit object BooleanImpl extends CanExtract[Boolean] {
    override def parse(data: String): Option[Boolean] = Try(data.toBoolean).toOption
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy