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

scala.googleapis.bigquery.TableFieldSchemaRoundingMode.scala Maven / Gradle / Ivy

There is a newer version: 0.6.1-v2-20241111
Show newest version
package googleapis.bigquery

import io.circe._

sealed abstract class TableFieldSchemaRoundingMode(val value: String)
    extends Product
    with Serializable
object TableFieldSchemaRoundingMode {

  /** Unspecified will default to using ROUND_HALF_AWAY_FROM_ZERO.
    */
  case object ROUNDING_MODE_UNSPECIFIED
      extends TableFieldSchemaRoundingMode("ROUNDING_MODE_UNSPECIFIED")

  /** ROUND_HALF_AWAY_FROM_ZERO rounds half values away from zero when applying precision and scale upon writing of NUMERIC and BIGNUMERIC values. For Scale: 0 1.1, 1.2, 1.3, 1.4 => 1 1.5, 1.6, 1.7, 1.8, 1.9 => 2
    */
  case object ROUND_HALF_AWAY_FROM_ZERO
      extends TableFieldSchemaRoundingMode("ROUND_HALF_AWAY_FROM_ZERO")

  /** ROUND_HALF_EVEN rounds half values to the nearest even value when applying precision and scale upon writing of NUMERIC and BIGNUMERIC values. For Scale: 0 1.1, 1.2, 1.3, 1.4 => 1 1.5 => 2 1.6, 1.7, 1.8, 1.9 => 2 2.5 => 2
    */
  case object ROUND_HALF_EVEN extends TableFieldSchemaRoundingMode("ROUND_HALF_EVEN")
  val values = List(ROUNDING_MODE_UNSPECIFIED, ROUND_HALF_AWAY_FROM_ZERO, ROUND_HALF_EVEN)
  def fromString(input: String): Either[String, TableFieldSchemaRoundingMode] = values
    .find(_.value == input)
    .toRight(s"'$input' was not a valid value for TableFieldSchemaRoundingMode")
  implicit val decoder: Decoder[TableFieldSchemaRoundingMode] =
    Decoder[String].emap(s => fromString(s))
  implicit val encoder: Encoder[TableFieldSchemaRoundingMode] = Encoder[String].contramap(_.value)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy