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

scalapb.fs2.pubsub.grpc.internal.Button.scala Maven / Gradle / Ivy

// Generated by the Scala Plugin for the Protocol Buffer Compiler.
// Do not edit!
//
// Protofile syntax: PROTO3

package fs2.pubsub.grpc.internal

/** A text, icon, or text and icon button that users can click. For an example in
  * Google Chat apps, see
  * [Add a
  * button](https://developers.google.com/workspace/chat/design-interactive-card-dialog#add_a_button).
  *
  * To make an image a clickable button, specify an
  * [`Image`][google.apps.card.v1.Image] (not an
  * [`ImageComponent`][google.apps.card.v1.ImageComponent]) and set an
  * `onClick` action.
  *
  * [Google Workspace
  * Add-ons and Chat apps](https://developers.google.com/workspace/extend):
  *
  * @param text
  *   The text displayed inside the button.
  * @param icon
  *   The icon image. If both `icon` and `text` are set, then the icon appears
  *   before the text.
  * @param color
  *   If set, the button is filled with a solid background color and the font
  *   color changes to maintain contrast with the background color. For example,
  *   setting a blue background likely results in white text.
  *  
  *   If unset, the image background is white and the font color is blue.
  *  
  *   For red, green, and blue, the value of each field is a `float` number that
  *   you can express in either of two ways: as a number between 0 and 255
  *   divided by 255 (153/255), or as a value between 0 and 1 (0.6). 0 represents
  *   the absence of a color and 1 or 255/255 represent the full presence of that
  *   color on the RGB scale.
  *  
  *   Optionally set `alpha`, which sets a level of transparency using this
  *   equation:
  *  
  *   ```
  *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
  *   ```
  *  
  *   For `alpha`, a value of `1` corresponds with a solid color, and a value of
  *   `0` corresponds with a completely transparent color.
  *  
  *   For example, the following color represents a half transparent red:
  *  
  *   ```
  *   "color": {
  *      "red": 1,
  *      "green": 0,
  *      "blue": 0,
  *      "alpha": 0.5
  *   }
  *   ```
  * @param onClick
  *   Required. The action to perform when a user clicks the button, such as
  *   opening a hyperlink or running a custom function.
  * @param disabled
  *   If `true`, the button is displayed in an inactive state and doesn't respond
  *   to user actions.
  * @param altText
  *   The alternative text that's used for accessibility.
  *  
  *   Set descriptive text that lets users know what the button does. For
  *   example, if a button opens a hyperlink, you might write: "Opens a new
  *   browser tab and navigates to the Google Chat developer documentation at
  *   https://developers.google.com/workspace/chat".
  */
@SerialVersionUID(0L)
@scala.annotation.nowarn private[grpc]
final case class Button(
    text: _root_.scala.Predef.String = "",
    icon: _root_.scala.Option[fs2.pubsub.grpc.internal.Icon] = _root_.scala.None,
    color: _root_.scala.Option[fs2.pubsub.grpc.internal.Color] = _root_.scala.None,
    onClick: _root_.scala.Option[fs2.pubsub.grpc.internal.OnClick] = _root_.scala.None,
    disabled: _root_.scala.Boolean = false,
    altText: _root_.scala.Predef.String = "",
    unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty
    ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[Button] {
    @transient
    private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
    private[this] def __computeSerializedSize(): _root_.scala.Int = {
      var __size = 0
      
      {
        val __value = text
        if (!__value.isEmpty) {
          __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(1, __value)
        }
      };
      if (icon.isDefined) {
        val __value = icon.get
        __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize
      };
      if (color.isDefined) {
        val __value = color.get
        __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize
      };
      if (onClick.isDefined) {
        val __value = onClick.get
        __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize
      };
      
      {
        val __value = disabled
        if (__value != false) {
          __size += _root_.com.google.protobuf.CodedOutputStream.computeBoolSize(5, __value)
        }
      };
      
      {
        val __value = altText
        if (!__value.isEmpty) {
          __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(6, __value)
        }
      };
      __size += unknownFields.serializedSize
      __size
    }
    override def serializedSize: _root_.scala.Int = {
      var __size = __serializedSizeMemoized
      if (__size == 0) {
        __size = __computeSerializedSize() + 1
        __serializedSizeMemoized = __size
      }
      __size - 1
      
    }
    def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = {
      {
        val __v = text
        if (!__v.isEmpty) {
          _output__.writeString(1, __v)
        }
      };
      icon.foreach { __v =>
        val __m = __v
        _output__.writeTag(2, 2)
        _output__.writeUInt32NoTag(__m.serializedSize)
        __m.writeTo(_output__)
      };
      color.foreach { __v =>
        val __m = __v
        _output__.writeTag(3, 2)
        _output__.writeUInt32NoTag(__m.serializedSize)
        __m.writeTo(_output__)
      };
      onClick.foreach { __v =>
        val __m = __v
        _output__.writeTag(4, 2)
        _output__.writeUInt32NoTag(__m.serializedSize)
        __m.writeTo(_output__)
      };
      {
        val __v = disabled
        if (__v != false) {
          _output__.writeBool(5, __v)
        }
      };
      {
        val __v = altText
        if (!__v.isEmpty) {
          _output__.writeString(6, __v)
        }
      };
      unknownFields.writeTo(_output__)
    }
    def withText(__v: _root_.scala.Predef.String): Button = copy(text = __v)
    def getIcon: fs2.pubsub.grpc.internal.Icon = icon.getOrElse(fs2.pubsub.grpc.internal.Icon.defaultInstance)
    def clearIcon: Button = copy(icon = _root_.scala.None)
    def withIcon(__v: fs2.pubsub.grpc.internal.Icon): Button = copy(icon = Option(__v))
    def getColor: fs2.pubsub.grpc.internal.Color = color.getOrElse(fs2.pubsub.grpc.internal.Color.defaultInstance)
    def clearColor: Button = copy(color = _root_.scala.None)
    def withColor(__v: fs2.pubsub.grpc.internal.Color): Button = copy(color = Option(__v))
    def getOnClick: fs2.pubsub.grpc.internal.OnClick = onClick.getOrElse(fs2.pubsub.grpc.internal.OnClick.defaultInstance)
    def clearOnClick: Button = copy(onClick = _root_.scala.None)
    def withOnClick(__v: fs2.pubsub.grpc.internal.OnClick): Button = copy(onClick = Option(__v))
    def withDisabled(__v: _root_.scala.Boolean): Button = copy(disabled = __v)
    def withAltText(__v: _root_.scala.Predef.String): Button = copy(altText = __v)
    def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v)
    def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty)
    def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = {
      (__fieldNumber: @_root_.scala.unchecked) match {
        case 1 => {
          val __t = text
          if (__t != "") __t else null
        }
        case 2 => icon.orNull
        case 3 => color.orNull
        case 4 => onClick.orNull
        case 5 => {
          val __t = disabled
          if (__t != false) __t else null
        }
        case 6 => {
          val __t = altText
          if (__t != "") __t else null
        }
      }
    }
    def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = {
      _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor)
      (__field.number: @_root_.scala.unchecked) match {
        case 1 => _root_.scalapb.descriptors.PString(text)
        case 2 => icon.map(_.toPMessage).getOrElse(_root_.scalapb.descriptors.PEmpty)
        case 3 => color.map(_.toPMessage).getOrElse(_root_.scalapb.descriptors.PEmpty)
        case 4 => onClick.map(_.toPMessage).getOrElse(_root_.scalapb.descriptors.PEmpty)
        case 5 => _root_.scalapb.descriptors.PBoolean(disabled)
        case 6 => _root_.scalapb.descriptors.PString(altText)
      }
    }
    def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this)
    def companion: fs2.pubsub.grpc.internal.Button.type = fs2.pubsub.grpc.internal.Button
    // @@protoc_insertion_point(GeneratedMessage[google.apps.card.v1.Button])
}

@scala.annotation.nowarn private[grpc]
object Button extends scalapb.GeneratedMessageCompanion[fs2.pubsub.grpc.internal.Button] {
  implicit def messageCompanion: scalapb.GeneratedMessageCompanion[fs2.pubsub.grpc.internal.Button] = this
  def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): fs2.pubsub.grpc.internal.Button = {
    var __text: _root_.scala.Predef.String = ""
    var __icon: _root_.scala.Option[fs2.pubsub.grpc.internal.Icon] = _root_.scala.None
    var __color: _root_.scala.Option[fs2.pubsub.grpc.internal.Color] = _root_.scala.None
    var __onClick: _root_.scala.Option[fs2.pubsub.grpc.internal.OnClick] = _root_.scala.None
    var __disabled: _root_.scala.Boolean = false
    var __altText: _root_.scala.Predef.String = ""
    var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null
    var _done__ = false
    while (!_done__) {
      val _tag__ = _input__.readTag()
      _tag__ match {
        case 0 => _done__ = true
        case 10 =>
          __text = _input__.readStringRequireUtf8()
        case 18 =>
          __icon = Option(__icon.fold(_root_.scalapb.LiteParser.readMessage[fs2.pubsub.grpc.internal.Icon](_input__))(_root_.scalapb.LiteParser.readMessage(_input__, _)))
        case 26 =>
          __color = Option(__color.fold(_root_.scalapb.LiteParser.readMessage[fs2.pubsub.grpc.internal.Color](_input__))(_root_.scalapb.LiteParser.readMessage(_input__, _)))
        case 34 =>
          __onClick = Option(__onClick.fold(_root_.scalapb.LiteParser.readMessage[fs2.pubsub.grpc.internal.OnClick](_input__))(_root_.scalapb.LiteParser.readMessage(_input__, _)))
        case 40 =>
          __disabled = _input__.readBool()
        case 50 =>
          __altText = _input__.readStringRequireUtf8()
        case tag =>
          if (_unknownFields__ == null) {
            _unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
          }
          _unknownFields__.parseField(tag, _input__)
      }
    }
    fs2.pubsub.grpc.internal.Button(
        text = __text,
        icon = __icon,
        color = __color,
        onClick = __onClick,
        disabled = __disabled,
        altText = __altText,
        unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result()
    )
  }
  implicit def messageReads: _root_.scalapb.descriptors.Reads[fs2.pubsub.grpc.internal.Button] = _root_.scalapb.descriptors.Reads{
    case _root_.scalapb.descriptors.PMessage(__fieldsMap) =>
      _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.")
      fs2.pubsub.grpc.internal.Button(
        text = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scala.Predef.String]).getOrElse(""),
        icon = __fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).flatMap(_.as[_root_.scala.Option[fs2.pubsub.grpc.internal.Icon]]),
        color = __fieldsMap.get(scalaDescriptor.findFieldByNumber(3).get).flatMap(_.as[_root_.scala.Option[fs2.pubsub.grpc.internal.Color]]),
        onClick = __fieldsMap.get(scalaDescriptor.findFieldByNumber(4).get).flatMap(_.as[_root_.scala.Option[fs2.pubsub.grpc.internal.OnClick]]),
        disabled = __fieldsMap.get(scalaDescriptor.findFieldByNumber(5).get).map(_.as[_root_.scala.Boolean]).getOrElse(false),
        altText = __fieldsMap.get(scalaDescriptor.findFieldByNumber(6).get).map(_.as[_root_.scala.Predef.String]).getOrElse("")
      )
    case _ => throw new RuntimeException("Expected PMessage")
  }
  def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = CardProto.javaDescriptor.getMessageTypes().get(11)
  def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = CardProto.scalaDescriptor.messages(11)
  def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = {
    var __out: _root_.scalapb.GeneratedMessageCompanion[_] = null
    (__number: @_root_.scala.unchecked) match {
      case 2 => __out = fs2.pubsub.grpc.internal.Icon
      case 3 => __out = fs2.pubsub.grpc.internal.Color
      case 4 => __out = fs2.pubsub.grpc.internal.OnClick
    }
    __out
  }
  lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty
  def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber)
  lazy val defaultInstance = fs2.pubsub.grpc.internal.Button(
    text = "",
    icon = _root_.scala.None,
    color = _root_.scala.None,
    onClick = _root_.scala.None,
    disabled = false,
    altText = ""
  )
  implicit class ButtonLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, fs2.pubsub.grpc.internal.Button]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, fs2.pubsub.grpc.internal.Button](_l) {
    def text: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.text)((c_, f_) => c_.copy(text = f_))
    def icon: _root_.scalapb.lenses.Lens[UpperPB, fs2.pubsub.grpc.internal.Icon] = field(_.getIcon)((c_, f_) => c_.copy(icon = Option(f_)))
    def optionalIcon: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Option[fs2.pubsub.grpc.internal.Icon]] = field(_.icon)((c_, f_) => c_.copy(icon = f_))
    def color: _root_.scalapb.lenses.Lens[UpperPB, fs2.pubsub.grpc.internal.Color] = field(_.getColor)((c_, f_) => c_.copy(color = Option(f_)))
    def optionalColor: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Option[fs2.pubsub.grpc.internal.Color]] = field(_.color)((c_, f_) => c_.copy(color = f_))
    def onClick: _root_.scalapb.lenses.Lens[UpperPB, fs2.pubsub.grpc.internal.OnClick] = field(_.getOnClick)((c_, f_) => c_.copy(onClick = Option(f_)))
    def optionalOnClick: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Option[fs2.pubsub.grpc.internal.OnClick]] = field(_.onClick)((c_, f_) => c_.copy(onClick = f_))
    def disabled: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Boolean] = field(_.disabled)((c_, f_) => c_.copy(disabled = f_))
    def altText: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.altText)((c_, f_) => c_.copy(altText = f_))
  }
  final val TEXT_FIELD_NUMBER = 1
  final val ICON_FIELD_NUMBER = 2
  final val COLOR_FIELD_NUMBER = 3
  final val ON_CLICK_FIELD_NUMBER = 4
  final val DISABLED_FIELD_NUMBER = 5
  final val ALT_TEXT_FIELD_NUMBER = 6
  def of(
    text: _root_.scala.Predef.String,
    icon: _root_.scala.Option[fs2.pubsub.grpc.internal.Icon],
    color: _root_.scala.Option[fs2.pubsub.grpc.internal.Color],
    onClick: _root_.scala.Option[fs2.pubsub.grpc.internal.OnClick],
    disabled: _root_.scala.Boolean,
    altText: _root_.scala.Predef.String
  ): _root_.fs2.pubsub.grpc.internal.Button = _root_.fs2.pubsub.grpc.internal.Button(
    text,
    icon,
    color,
    onClick,
    disabled,
    altText
  )
  // @@protoc_insertion_point(GeneratedMessageCompanion[google.apps.card.v1.Button])
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy