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

io.kinoplan.utils.implicits.AnySyntax.scala Maven / Gradle / Ivy

package io.kinoplan.utils.implicits

final private[implicits] class AnyOps(private val value: Any) extends AnyVal {

  @inline
  def toIntOption: Option[Int] = value match {
    case i: Int    => Some(i)
    case d: Double => Some(d.toInt)
    case f: Float  => Some(f.toInt)
    case l: Long   => Some(l.toInt)
    case s: String => s.toIntOption
    case _         => None
  }

}

trait AnySyntax {
  implicit final def syntaxAnyOps(value: Any): AnyOps = new AnyOps(value)
}

object AnySyntax extends AnySyntax




© 2015 - 2025 Weber Informatics LLC | Privacy Policy