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

io.github.vigoo.zioaws.rdsdata.model.Field.scala Maven / Gradle / Ivy

There is a newer version: 4.17.280.4
Show newest version
package io.github.vigoo.zioaws.rdsdata.model
import zio.ZIO
import io.github.vigoo.zioaws.rdsdata.model.primitives.{
  BoxedLong,
  BoxedDouble,
  BoxedBoolean,
  Blob
}
import io.github.vigoo.zioaws.core.{AwsError, BuilderHelper}
import scala.jdk.CollectionConverters.*
final case class Field(
    arrayValue: Option[io.github.vigoo.zioaws.rdsdata.model.ArrayValue] = None,
    blobValue: Option[Blob] = None,
    booleanValue: Option[BoxedBoolean] = None,
    doubleValue: Option[BoxedDouble] = None,
    isNull: Option[BoxedBoolean] = None,
    longValue: Option[BoxedLong] = None,
    stringValue: Option[String] = None
) {
  def buildAwsValue(): software.amazon.awssdk.services.rdsdata.model.Field = {
    import Field.zioAwsBuilderHelper.BuilderOps
    software.amazon.awssdk.services.rdsdata.model.Field
      .builder()
      .optionallyWith(arrayValue.map(value => value.buildAwsValue()))(
        _.arrayValue
      )
      .optionallyWith(
        blobValue.map(value =>
          software.amazon.awssdk.core.SdkBytes.fromByteArrayUnsafe(
            value.toArray[Byte]
          )
        )
      )(_.blobValue)
      .optionallyWith(booleanValue.map(value => value: java.lang.Boolean))(
        _.booleanValue
      )
      .optionallyWith(doubleValue.map(value => value: java.lang.Double))(
        _.doubleValue
      )
      .optionallyWith(isNull.map(value => value: java.lang.Boolean))(_.isNull)
      .optionallyWith(longValue.map(value => value: java.lang.Long))(
        _.longValue
      )
      .optionallyWith(stringValue.map(value => value: java.lang.String))(
        _.stringValue
      )
      .build()
  }
  def asReadOnly: io.github.vigoo.zioaws.rdsdata.model.Field.ReadOnly =
    io.github.vigoo.zioaws.rdsdata.model.Field.wrap(buildAwsValue())
}
object Field {
  private lazy val zioAwsBuilderHelper
      : BuilderHelper[software.amazon.awssdk.services.rdsdata.model.Field] =
    BuilderHelper.apply
  trait ReadOnly {
    def editable: io.github.vigoo.zioaws.rdsdata.model.Field =
      io.github.vigoo.zioaws.rdsdata.model.Field(
        arrayValueValue.map(value => value.editable),
        blobValueValue.map(value => value),
        booleanValueValue.map(value => value),
        doubleValueValue.map(value => value),
        isNullValue.map(value => value),
        longValueValue.map(value => value),
        stringValueValue.map(value => value)
      )
    def arrayValueValue
        : Option[io.github.vigoo.zioaws.rdsdata.model.ArrayValue.ReadOnly]
    def blobValueValue: Option[Blob]
    def booleanValueValue: Option[BoxedBoolean]
    def doubleValueValue: Option[BoxedDouble]
    def isNullValue: Option[BoxedBoolean]
    def longValueValue: Option[BoxedLong]
    def stringValueValue: Option[String]
    def arrayValue: ZIO[
      Any,
      AwsError,
      io.github.vigoo.zioaws.rdsdata.model.ArrayValue.ReadOnly
    ] = AwsError.unwrapOptionField("arrayValue", arrayValueValue)
    def blobValue: ZIO[Any, AwsError, Blob] =
      AwsError.unwrapOptionField("blobValue", blobValueValue)
    def booleanValue: ZIO[Any, AwsError, BoxedBoolean] =
      AwsError.unwrapOptionField("booleanValue", booleanValueValue)
    def doubleValue: ZIO[Any, AwsError, BoxedDouble] =
      AwsError.unwrapOptionField("doubleValue", doubleValueValue)
    def isNull: ZIO[Any, AwsError, BoxedBoolean] =
      AwsError.unwrapOptionField("isNull", isNullValue)
    def longValue: ZIO[Any, AwsError, BoxedLong] =
      AwsError.unwrapOptionField("longValue", longValueValue)
    def stringValue: ZIO[Any, AwsError, String] =
      AwsError.unwrapOptionField("stringValue", stringValueValue)
  }
  private class Wrapper(
      impl: software.amazon.awssdk.services.rdsdata.model.Field
  ) extends io.github.vigoo.zioaws.rdsdata.model.Field.ReadOnly {
    override def arrayValueValue
        : Option[io.github.vigoo.zioaws.rdsdata.model.ArrayValue.ReadOnly] =
      scala
        .Option(impl.arrayValue())
        .map(value =>
          io.github.vigoo.zioaws.rdsdata.model.ArrayValue.wrap(value)
        )
    override def blobValueValue: Option[Blob] = scala
      .Option(impl.blobValue())
      .map(value => zio.Chunk.fromArray(value.asByteArrayUnsafe()))
    override def booleanValueValue: Option[BoxedBoolean] =
      scala.Option(impl.booleanValue()).map(value => value: BoxedBoolean)
    override def doubleValueValue: Option[BoxedDouble] =
      scala.Option(impl.doubleValue()).map(value => value: BoxedDouble)
    override def isNullValue: Option[BoxedBoolean] =
      scala.Option(impl.isNull()).map(value => value: BoxedBoolean)
    override def longValueValue: Option[BoxedLong] =
      scala.Option(impl.longValue()).map(value => value: BoxedLong)
    override def stringValueValue: Option[String] =
      scala.Option(impl.stringValue()).map(value => value: String)
  }
  def wrap(
      impl: software.amazon.awssdk.services.rdsdata.model.Field
  ): io.github.vigoo.zioaws.rdsdata.model.Field.ReadOnly = new Wrapper(impl)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy