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

beaker.server.protobuf.Proposal.scala Maven / Gradle / Ivy

The newest version!
// Generated by the Scala Plugin for the Protocol Buffer Compiler.
// Do not edit!
//
// Protofile syntax: PROTO2

package beaker.server.protobuf

/** *
  * A collection of non-conflicting transactions.
  *
  * @param ballot Unique identifier.
  * @param commits Transactions committed by the proposal.
  * @param repairs Keys repaired by the proposal.
  * @param view Current network configuration.
  */
@SerialVersionUID(0L)
final case class Proposal(
    ballot: beaker.server.protobuf.Ballot,
    commits: _root_.scala.collection.Seq[beaker.server.protobuf.Transaction] = _root_.scala.collection.Seq.empty,
    repairs: scala.collection.immutable.Map[_root_.scala.Predef.String, beaker.server.protobuf.Revision] = scala.collection.immutable.Map.empty,
    view: beaker.server.protobuf.View
    ) extends scalapb.GeneratedMessage with scalapb.Message[Proposal] with scalapb.lenses.Updatable[Proposal] {
    @transient
    private[this] var __serializedSizeCachedValue: _root_.scala.Int = 0
    private[this] def __computeSerializedValue(): _root_.scala.Int = {
      var __size = 0
      __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(ballot.serializedSize) + ballot.serializedSize
      commits.foreach(commits => __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(commits.serializedSize) + commits.serializedSize)
      repairs.foreach(repairs => __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(beaker.server.protobuf.Proposal._typemapper_repairs.toBase(repairs).serializedSize) + beaker.server.protobuf.Proposal._typemapper_repairs.toBase(repairs).serializedSize)
      __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(view.serializedSize) + view.serializedSize
      __size
    }
    final override def serializedSize: _root_.scala.Int = {
      var read = __serializedSizeCachedValue
      if (read == 0) {
        read = __computeSerializedValue()
        __serializedSizeCachedValue = read
      }
      read
    }
    def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = {
      _output__.writeTag(1, 2)
      _output__.writeUInt32NoTag(ballot.serializedSize)
      ballot.writeTo(_output__)
      commits.foreach { __v =>
        _output__.writeTag(2, 2)
        _output__.writeUInt32NoTag(__v.serializedSize)
        __v.writeTo(_output__)
      };
      repairs.foreach { __v =>
        _output__.writeTag(3, 2)
        _output__.writeUInt32NoTag(beaker.server.protobuf.Proposal._typemapper_repairs.toBase(__v).serializedSize)
        beaker.server.protobuf.Proposal._typemapper_repairs.toBase(__v).writeTo(_output__)
      };
      _output__.writeTag(4, 2)
      _output__.writeUInt32NoTag(view.serializedSize)
      view.writeTo(_output__)
    }
    def mergeFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): beaker.server.protobuf.Proposal = {
      var __ballot = this.ballot
      val __commits = (_root_.scala.collection.immutable.Vector.newBuilder[beaker.server.protobuf.Transaction] ++= this.commits)
      val __repairs = (scala.collection.immutable.Map.newBuilder[_root_.scala.Predef.String, beaker.server.protobuf.Revision] ++= this.repairs)
      var __view = this.view
      var __requiredFields0: _root_.scala.Long = 0x3L
      var _done__ = false
      while (!_done__) {
        val _tag__ = _input__.readTag()
        _tag__ match {
          case 0 => _done__ = true
          case 10 =>
            __ballot = _root_.scalapb.LiteParser.readMessage(_input__, __ballot)
            __requiredFields0 &= 0xfffffffffffffffeL
          case 18 =>
            __commits += _root_.scalapb.LiteParser.readMessage(_input__, beaker.server.protobuf.Transaction.defaultInstance)
          case 26 =>
            __repairs += beaker.server.protobuf.Proposal._typemapper_repairs.toCustom(_root_.scalapb.LiteParser.readMessage(_input__, beaker.server.protobuf.Proposal.RepairsEntry.defaultInstance))
          case 34 =>
            __view = _root_.scalapb.LiteParser.readMessage(_input__, __view)
            __requiredFields0 &= 0xfffffffffffffffdL
          case tag => _input__.skipField(tag)
        }
      }
      if (__requiredFields0 != 0L) { throw new _root_.com.google.protobuf.InvalidProtocolBufferException("Message missing required fields.") } 
      beaker.server.protobuf.Proposal(
          ballot = __ballot,
          commits = __commits.result(),
          repairs = __repairs.result(),
          view = __view
      )
    }
    def withBallot(__v: beaker.server.protobuf.Ballot): Proposal = copy(ballot = __v)
    def clearCommits = copy(commits = _root_.scala.collection.Seq.empty)
    def addCommits(__vs: beaker.server.protobuf.Transaction*): Proposal = addAllCommits(__vs)
    def addAllCommits(__vs: TraversableOnce[beaker.server.protobuf.Transaction]): Proposal = copy(commits = commits ++ __vs)
    def withCommits(__v: _root_.scala.collection.Seq[beaker.server.protobuf.Transaction]): Proposal = copy(commits = __v)
    def clearRepairs = copy(repairs = scala.collection.immutable.Map.empty)
    def addRepairs(__vs: (_root_.scala.Predef.String, beaker.server.protobuf.Revision)*): Proposal = addAllRepairs(__vs)
    def addAllRepairs(__vs: TraversableOnce[(_root_.scala.Predef.String, beaker.server.protobuf.Revision)]): Proposal = copy(repairs = repairs ++ __vs)
    def withRepairs(__v: scala.collection.immutable.Map[_root_.scala.Predef.String, beaker.server.protobuf.Revision]): Proposal = copy(repairs = __v)
    def withView(__v: beaker.server.protobuf.View): Proposal = copy(view = __v)
    def getFieldByNumber(__fieldNumber: _root_.scala.Int): scala.Any = {
      (__fieldNumber: @_root_.scala.unchecked) match {
        case 1 => ballot
        case 2 => commits
        case 3 => repairs.map(beaker.server.protobuf.Proposal._typemapper_repairs.toBase)(_root_.scala.collection.breakOut)
        case 4 => view
      }
    }
    def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = {
      require(__field.containingMessage eq companion.scalaDescriptor)
      (__field.number: @_root_.scala.unchecked) match {
        case 1 => ballot.toPMessage
        case 2 => _root_.scalapb.descriptors.PRepeated(commits.map(_.toPMessage)(_root_.scala.collection.breakOut))
        case 3 => _root_.scalapb.descriptors.PRepeated(repairs.map(beaker.server.protobuf.Proposal._typemapper_repairs.toBase(_).toPMessage)(_root_.scala.collection.breakOut))
        case 4 => view.toPMessage
      }
    }
    def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this)
    def companion = beaker.server.protobuf.Proposal
}

object Proposal extends scalapb.GeneratedMessageCompanion[beaker.server.protobuf.Proposal] {
  implicit def messageCompanion: scalapb.GeneratedMessageCompanion[beaker.server.protobuf.Proposal] = this
  def fromFieldsMap(__fieldsMap: scala.collection.immutable.Map[_root_.com.google.protobuf.Descriptors.FieldDescriptor, scala.Any]): beaker.server.protobuf.Proposal = {
    require(__fieldsMap.keys.forall(_.getContainingType() == javaDescriptor), "FieldDescriptor does not match message type.")
    val __fields = javaDescriptor.getFields
    beaker.server.protobuf.Proposal(
      __fieldsMap(__fields.get(0)).asInstanceOf[beaker.server.protobuf.Ballot],
      __fieldsMap.getOrElse(__fields.get(1), Nil).asInstanceOf[_root_.scala.collection.Seq[beaker.server.protobuf.Transaction]],
      __fieldsMap.getOrElse(__fields.get(2), Nil).asInstanceOf[_root_.scala.collection.Seq[beaker.server.protobuf.Proposal.RepairsEntry]].map(beaker.server.protobuf.Proposal._typemapper_repairs.toCustom)(_root_.scala.collection.breakOut),
      __fieldsMap(__fields.get(3)).asInstanceOf[beaker.server.protobuf.View]
    )
  }
  implicit def messageReads: _root_.scalapb.descriptors.Reads[beaker.server.protobuf.Proposal] = _root_.scalapb.descriptors.Reads{
    case _root_.scalapb.descriptors.PMessage(__fieldsMap) =>
      require(__fieldsMap.keys.forall(_.containingMessage == scalaDescriptor), "FieldDescriptor does not match message type.")
      beaker.server.protobuf.Proposal(
        __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).get.as[beaker.server.protobuf.Ballot],
        __fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).map(_.as[_root_.scala.collection.Seq[beaker.server.protobuf.Transaction]]).getOrElse(_root_.scala.collection.Seq.empty),
        __fieldsMap.get(scalaDescriptor.findFieldByNumber(3).get).map(_.as[_root_.scala.collection.Seq[beaker.server.protobuf.Proposal.RepairsEntry]]).getOrElse(_root_.scala.collection.Seq.empty).map(beaker.server.protobuf.Proposal._typemapper_repairs.toCustom)(_root_.scala.collection.breakOut),
        __fieldsMap.get(scalaDescriptor.findFieldByNumber(4).get).get.as[beaker.server.protobuf.View]
      )
    case _ => throw new RuntimeException("Expected PMessage")
  }
  def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = BeakerProto.javaDescriptor.getMessageTypes.get(11)
  def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = BeakerProto.scalaDescriptor.messages(11)
  def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = {
    var __out: _root_.scalapb.GeneratedMessageCompanion[_] = null
    (__number: @_root_.scala.unchecked) match {
      case 1 => __out = beaker.server.protobuf.Ballot
      case 2 => __out = beaker.server.protobuf.Transaction
      case 3 => __out = beaker.server.protobuf.Proposal.RepairsEntry
      case 4 => __out = beaker.server.protobuf.View
    }
    __out
  }
  lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_]] = Seq[_root_.scalapb.GeneratedMessageCompanion[_]](
    _root_.beaker.server.protobuf.Proposal.RepairsEntry
  )
  def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber)
  lazy val defaultInstance = beaker.server.protobuf.Proposal(
    ballot = beaker.server.protobuf.Ballot.defaultInstance,
    view = beaker.server.protobuf.View.defaultInstance
  )
  @SerialVersionUID(0L)
  final case class RepairsEntry(
      key: scala.Option[_root_.scala.Predef.String] = None,
      value: scala.Option[beaker.server.protobuf.Revision] = None
      ) extends scalapb.GeneratedMessage with scalapb.Message[RepairsEntry] with scalapb.lenses.Updatable[RepairsEntry] {
      @transient
      private[this] var __serializedSizeCachedValue: _root_.scala.Int = 0
      private[this] def __computeSerializedValue(): _root_.scala.Int = {
        var __size = 0
        if (key.isDefined) { __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(1, key.get) }
        if (value.isDefined) { __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(value.get.serializedSize) + value.get.serializedSize }
        __size
      }
      final override def serializedSize: _root_.scala.Int = {
        var read = __serializedSizeCachedValue
        if (read == 0) {
          read = __computeSerializedValue()
          __serializedSizeCachedValue = read
        }
        read
      }
      def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = {
        key.foreach { __v =>
          _output__.writeString(1, __v)
        };
        value.foreach { __v =>
          _output__.writeTag(2, 2)
          _output__.writeUInt32NoTag(__v.serializedSize)
          __v.writeTo(_output__)
        };
      }
      def mergeFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): beaker.server.protobuf.Proposal.RepairsEntry = {
        var __key = this.key
        var __value = this.value
        var _done__ = false
        while (!_done__) {
          val _tag__ = _input__.readTag()
          _tag__ match {
            case 0 => _done__ = true
            case 10 =>
              __key = Option(_input__.readString())
            case 18 =>
              __value = Option(_root_.scalapb.LiteParser.readMessage(_input__, __value.getOrElse(beaker.server.protobuf.Revision.defaultInstance)))
            case tag => _input__.skipField(tag)
          }
        }
        beaker.server.protobuf.Proposal.RepairsEntry(
            key = __key,
            value = __value
        )
      }
      def getKey: _root_.scala.Predef.String = key.getOrElse("")
      def clearKey: RepairsEntry = copy(key = None)
      def withKey(__v: _root_.scala.Predef.String): RepairsEntry = copy(key = Option(__v))
      def getValue: beaker.server.protobuf.Revision = value.getOrElse(beaker.server.protobuf.Revision.defaultInstance)
      def clearValue: RepairsEntry = copy(value = None)
      def withValue(__v: beaker.server.protobuf.Revision): RepairsEntry = copy(value = Option(__v))
      def getFieldByNumber(__fieldNumber: _root_.scala.Int): scala.Any = {
        (__fieldNumber: @_root_.scala.unchecked) match {
          case 1 => key.orNull
          case 2 => value.orNull
        }
      }
      def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = {
        require(__field.containingMessage eq companion.scalaDescriptor)
        (__field.number: @_root_.scala.unchecked) match {
          case 1 => key.map(_root_.scalapb.descriptors.PString).getOrElse(_root_.scalapb.descriptors.PEmpty)
          case 2 => value.map(_.toPMessage).getOrElse(_root_.scalapb.descriptors.PEmpty)
        }
      }
      def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this)
      def companion = beaker.server.protobuf.Proposal.RepairsEntry
  }
  
  object RepairsEntry extends scalapb.GeneratedMessageCompanion[beaker.server.protobuf.Proposal.RepairsEntry] {
    implicit def messageCompanion: scalapb.GeneratedMessageCompanion[beaker.server.protobuf.Proposal.RepairsEntry] = this
    def fromFieldsMap(__fieldsMap: scala.collection.immutable.Map[_root_.com.google.protobuf.Descriptors.FieldDescriptor, scala.Any]): beaker.server.protobuf.Proposal.RepairsEntry = {
      require(__fieldsMap.keys.forall(_.getContainingType() == javaDescriptor), "FieldDescriptor does not match message type.")
      val __fields = javaDescriptor.getFields
      beaker.server.protobuf.Proposal.RepairsEntry(
        __fieldsMap.get(__fields.get(0)).asInstanceOf[scala.Option[_root_.scala.Predef.String]],
        __fieldsMap.get(__fields.get(1)).asInstanceOf[scala.Option[beaker.server.protobuf.Revision]]
      )
    }
    implicit def messageReads: _root_.scalapb.descriptors.Reads[beaker.server.protobuf.Proposal.RepairsEntry] = _root_.scalapb.descriptors.Reads{
      case _root_.scalapb.descriptors.PMessage(__fieldsMap) =>
        require(__fieldsMap.keys.forall(_.containingMessage == scalaDescriptor), "FieldDescriptor does not match message type.")
        beaker.server.protobuf.Proposal.RepairsEntry(
          __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).flatMap(_.as[scala.Option[_root_.scala.Predef.String]]),
          __fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).flatMap(_.as[scala.Option[beaker.server.protobuf.Revision]])
        )
      case _ => throw new RuntimeException("Expected PMessage")
    }
    def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = beaker.server.protobuf.Proposal.javaDescriptor.getNestedTypes.get(0)
    def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = beaker.server.protobuf.Proposal.scalaDescriptor.nestedMessages(0)
    def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = {
      var __out: _root_.scalapb.GeneratedMessageCompanion[_] = null
      (__number: @_root_.scala.unchecked) match {
        case 2 => __out = beaker.server.protobuf.Revision
      }
      __out
    }
    lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_]] = Seq.empty
    def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber)
    lazy val defaultInstance = beaker.server.protobuf.Proposal.RepairsEntry(
    )
    implicit class RepairsEntryLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, beaker.server.protobuf.Proposal.RepairsEntry]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, beaker.server.protobuf.Proposal.RepairsEntry](_l) {
      def key: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.getKey)((c_, f_) => c_.copy(key = Option(f_)))
      def optionalKey: _root_.scalapb.lenses.Lens[UpperPB, scala.Option[_root_.scala.Predef.String]] = field(_.key)((c_, f_) => c_.copy(key = f_))
      def value: _root_.scalapb.lenses.Lens[UpperPB, beaker.server.protobuf.Revision] = field(_.getValue)((c_, f_) => c_.copy(value = Option(f_)))
      def optionalValue: _root_.scalapb.lenses.Lens[UpperPB, scala.Option[beaker.server.protobuf.Revision]] = field(_.value)((c_, f_) => c_.copy(value = f_))
    }
    final val KEY_FIELD_NUMBER = 1
    final val VALUE_FIELD_NUMBER = 2
    implicit val keyValueMapper: _root_.scalapb.TypeMapper[beaker.server.protobuf.Proposal.RepairsEntry, (_root_.scala.Predef.String, beaker.server.protobuf.Revision)] =
      _root_.scalapb.TypeMapper[beaker.server.protobuf.Proposal.RepairsEntry, (_root_.scala.Predef.String, beaker.server.protobuf.Revision)](__m => (__m.getKey, __m.getValue))(__p => beaker.server.protobuf.Proposal.RepairsEntry(Some(__p._1), Some(__p._2)))
  }
  
  implicit class ProposalLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, beaker.server.protobuf.Proposal]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, beaker.server.protobuf.Proposal](_l) {
    def ballot: _root_.scalapb.lenses.Lens[UpperPB, beaker.server.protobuf.Ballot] = field(_.ballot)((c_, f_) => c_.copy(ballot = f_))
    def commits: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.collection.Seq[beaker.server.protobuf.Transaction]] = field(_.commits)((c_, f_) => c_.copy(commits = f_))
    def repairs: _root_.scalapb.lenses.Lens[UpperPB, scala.collection.immutable.Map[_root_.scala.Predef.String, beaker.server.protobuf.Revision]] = field(_.repairs)((c_, f_) => c_.copy(repairs = f_))
    def view: _root_.scalapb.lenses.Lens[UpperPB, beaker.server.protobuf.View] = field(_.view)((c_, f_) => c_.copy(view = f_))
  }
  final val BALLOT_FIELD_NUMBER = 1
  final val COMMITS_FIELD_NUMBER = 2
  final val REPAIRS_FIELD_NUMBER = 3
  final val VIEW_FIELD_NUMBER = 4
  @transient
  private val _typemapper_repairs: _root_.scalapb.TypeMapper[beaker.server.protobuf.Proposal.RepairsEntry, (_root_.scala.Predef.String, beaker.server.protobuf.Revision)] = implicitly[_root_.scalapb.TypeMapper[beaker.server.protobuf.Proposal.RepairsEntry, (_root_.scala.Predef.String, beaker.server.protobuf.Revision)]]
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy