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

ciris.decoders.MathConfigDecoders.scala Maven / Gradle / Ivy

There is a newer version: 0.12.1
Show newest version
package ciris.decoders

import ciris.ConfigDecoder
import java.math.{BigDecimal => JBigDecimal}
import java.math.{BigInteger => JBigInteger}

import scala.util.Try

trait MathConfigDecoders {
  implicit val bigIntConfigDecoder: ConfigDecoder[String, BigInt] =
    ConfigDecoder.fromTry("BigInt")(value => Try(BigInt(value)))

  implicit val bigDecimalConfigDecoder: ConfigDecoder[String, BigDecimal] =
    ConfigDecoder.fromTry("BigDecimal")(value => Try(BigDecimal(value)))

  implicit val javaBigDecimalConfigDecoder: ConfigDecoder[String, JBigDecimal] =
    bigDecimalConfigDecoder.map(_.underlying)

  implicit val javaBigIntegerConfigDecoder: ConfigDecoder[String, JBigInteger] =
    bigIntConfigDecoder.map(_.underlying)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy