-
Notifications
You must be signed in to change notification settings - Fork 348
/
resultsetconcurrency.scala
37 lines (25 loc) · 1.16 KB
/
resultsetconcurrency.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) 2013-2018 Rob Norris and Contributors
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT
package doobie.enum
import doobie.util.invariant._
import java.sql.ResultSet._
import cats.ApplicativeError
import cats.kernel.Eq
import cats.kernel.instances.int._
/** @group Types */
sealed abstract class ResultSetConcurrency(val toInt: Int) extends Product with Serializable
/** @group Modules */
object ResultSetConcurrency {
/** @group Values */ case object ConcurReadOnly extends ResultSetConcurrency(CONCUR_READ_ONLY)
/** @group Values */ case object ConcurUpdatable extends ResultSetConcurrency(CONCUR_UPDATABLE)
def fromInt(n:Int): Option[ResultSetConcurrency] =
Some(n) collect {
case ConcurReadOnly.toInt => ConcurReadOnly
case ConcurUpdatable.toInt => ConcurUpdatable
}
def fromIntF[F[_]](n: Int)(implicit AE: ApplicativeError[F, Throwable]): F[ResultSetConcurrency] =
ApplicativeError.liftFromOption(fromInt(n), InvalidOrdinal[ResultSetConcurrency](n))
implicit val EqResultSetConcurrency: Eq[ResultSetConcurrency] =
Eq.by(_.toInt)
}