doobie.enum.fetchdirection.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doobie-core_2.10 Show documentation
Show all versions of doobie-core_2.10 Show documentation
Pure functional JDBC layer for Scala.
The newest version!
package doobie.enum
import doobie.util.invariant._
import java.sql.ResultSet._
import scalaz.Equal
import scalaz.std.anyVal.intInstance
object fetchdirection {
/** @group Implementation */
sealed abstract class FetchDirection(val toInt: Int)
/** @group Values */ case object Forward extends FetchDirection(FETCH_FORWARD)
/** @group Values */ case object Reverse extends FetchDirection(FETCH_REVERSE)
/** @group Values */ case object Unknown extends FetchDirection(FETCH_UNKNOWN)
/** @group Implementation */
object FetchDirection {
def fromInt(n: Int): Option[FetchDirection] =
Some(n) collect {
case Forward.toInt => Forward
case Reverse.toInt => Reverse
case Unknown.toInt => Unknown
}
def unsafeFromInt(n: Int): FetchDirection =
fromInt(n).getOrElse(throw InvalidOrdinal[FetchDirection](n))
implicit val EqualFetchDirection: Equal[FetchDirection] =
Equal.equalBy(_.toInt)
}
}