
scalapb.fs2.pubsub.grpc.internal.Weight.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
/** The weight represented as the value in string and the unit.
*
* @param amountMicros
* Required. The weight represented as a number in micros (1 million micros is
* an equivalent to one's currency standard unit, for example, 1 kg = 1000000
* micros).
* This field can also be set as infinity by setting to -1.
* This field only support -1 and positive value.
* @param unit
* Required. The weight unit.
* Acceptable values are: kg and lb
*/
@SerialVersionUID(0L)
@scala.annotation.nowarn private[grpc]
final case class Weight(
amountMicros: _root_.scala.Option[_root_.scala.Long] = _root_.scala.None,
unit: fs2.pubsub.grpc.internal.Weight.WeightUnit = fs2.pubsub.grpc.internal.Weight.WeightUnit.WEIGHT_UNIT_UNSPECIFIED,
unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty
) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[Weight] {
@transient
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
if (amountMicros.isDefined) {
val __value = amountMicros.get
__size += _root_.com.google.protobuf.CodedOutputStream.computeInt64Size(1, __value)
};
{
val __value = unit.value
if (__value != 0) {
__size += _root_.com.google.protobuf.CodedOutputStream.computeEnumSize(2, __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 = {
amountMicros.foreach { __v =>
val __m = __v
_output__.writeInt64(1, __m)
};
{
val __v = unit.value
if (__v != 0) {
_output__.writeEnum(2, __v)
}
};
unknownFields.writeTo(_output__)
}
def getAmountMicros: _root_.scala.Long = amountMicros.getOrElse(0L)
def clearAmountMicros: Weight = copy(amountMicros = _root_.scala.None)
def withAmountMicros(__v: _root_.scala.Long): Weight = copy(amountMicros = Option(__v))
def withUnit(__v: fs2.pubsub.grpc.internal.Weight.WeightUnit): Weight = copy(unit = __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 => amountMicros.orNull
case 2 => {
val __t = unit.javaValueDescriptor
if (__t.getNumber() != 0) __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 => amountMicros.map(_root_.scalapb.descriptors.PLong(_)).getOrElse(_root_.scalapb.descriptors.PEmpty)
case 2 => _root_.scalapb.descriptors.PEnum(unit.scalaValueDescriptor)
}
}
def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this)
def companion: fs2.pubsub.grpc.internal.Weight.type = fs2.pubsub.grpc.internal.Weight
// @@protoc_insertion_point(GeneratedMessage[google.shopping.type.Weight])
}
@scala.annotation.nowarn private[grpc]
object Weight extends scalapb.GeneratedMessageCompanion[fs2.pubsub.grpc.internal.Weight] {
implicit def messageCompanion: scalapb.GeneratedMessageCompanion[fs2.pubsub.grpc.internal.Weight] = this
def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): fs2.pubsub.grpc.internal.Weight = {
var __amountMicros: _root_.scala.Option[_root_.scala.Long] = _root_.scala.None
var __unit: fs2.pubsub.grpc.internal.Weight.WeightUnit = fs2.pubsub.grpc.internal.Weight.WeightUnit.WEIGHT_UNIT_UNSPECIFIED
var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null
var _done__ = false
while (!_done__) {
val _tag__ = _input__.readTag()
_tag__ match {
case 0 => _done__ = true
case 8 =>
__amountMicros = Option(_input__.readInt64())
case 16 =>
__unit = fs2.pubsub.grpc.internal.Weight.WeightUnit.fromValue(_input__.readEnum())
case tag =>
if (_unknownFields__ == null) {
_unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
}
_unknownFields__.parseField(tag, _input__)
}
}
fs2.pubsub.grpc.internal.Weight(
amountMicros = __amountMicros,
unit = __unit,
unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result()
)
}
implicit def messageReads: _root_.scalapb.descriptors.Reads[fs2.pubsub.grpc.internal.Weight] = _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.Weight(
amountMicros = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).flatMap(_.as[_root_.scala.Option[_root_.scala.Long]]),
unit = fs2.pubsub.grpc.internal.Weight.WeightUnit.fromValue(__fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).map(_.as[_root_.scalapb.descriptors.EnumValueDescriptor]).getOrElse(fs2.pubsub.grpc.internal.Weight.WeightUnit.WEIGHT_UNIT_UNSPECIFIED.scalaValueDescriptor).number)
)
case _ => throw new RuntimeException("Expected PMessage")
}
def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = TypesProto.javaDescriptor.getMessageTypes().get(0)
def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = TypesProto.scalaDescriptor.messages(0)
def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = throw new MatchError(__number)
lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty
def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = {
(__fieldNumber: @_root_.scala.unchecked) match {
case 2 => fs2.pubsub.grpc.internal.Weight.WeightUnit
}
}
lazy val defaultInstance = fs2.pubsub.grpc.internal.Weight(
amountMicros = _root_.scala.None,
unit = fs2.pubsub.grpc.internal.Weight.WeightUnit.WEIGHT_UNIT_UNSPECIFIED
)
/** The weight unit.
*/
sealed abstract class WeightUnit(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum {
type EnumType = fs2.pubsub.grpc.internal.Weight.WeightUnit
type RecognizedType = fs2.pubsub.grpc.internal.Weight.WeightUnit.Recognized
def isWeightUnitUnspecified: _root_.scala.Boolean = false
def isPound: _root_.scala.Boolean = false
def isKilogram: _root_.scala.Boolean = false
def companion: _root_.scalapb.GeneratedEnumCompanion[WeightUnit] = fs2.pubsub.grpc.internal.Weight.WeightUnit
final def asRecognized: _root_.scala.Option[fs2.pubsub.grpc.internal.Weight.WeightUnit.Recognized] = if (isUnrecognized) _root_.scala.None else _root_.scala.Some(this.asInstanceOf[fs2.pubsub.grpc.internal.Weight.WeightUnit.Recognized])
}
object WeightUnit extends _root_.scalapb.GeneratedEnumCompanion[WeightUnit] {
sealed trait Recognized extends WeightUnit
implicit def enumCompanion: _root_.scalapb.GeneratedEnumCompanion[WeightUnit] = this
/** unit unspecified
*/
@SerialVersionUID(0L)
case object WEIGHT_UNIT_UNSPECIFIED extends WeightUnit(0) with WeightUnit.Recognized {
val index = 0
val name = "WEIGHT_UNIT_UNSPECIFIED"
override def isWeightUnitUnspecified: _root_.scala.Boolean = true
}
/** lb unit.
*/
@SerialVersionUID(0L)
case object POUND extends WeightUnit(1) with WeightUnit.Recognized {
val index = 1
val name = "POUND"
override def isPound: _root_.scala.Boolean = true
}
/** kg unit.
*/
@SerialVersionUID(0L)
case object KILOGRAM extends WeightUnit(2) with WeightUnit.Recognized {
val index = 2
val name = "KILOGRAM"
override def isKilogram: _root_.scala.Boolean = true
}
@SerialVersionUID(0L)
final case class Unrecognized(unrecognizedValue: _root_.scala.Int) extends WeightUnit(unrecognizedValue) with _root_.scalapb.UnrecognizedEnum
lazy val values: scala.collection.immutable.Seq[ValueType] = scala.collection.immutable.Seq(WEIGHT_UNIT_UNSPECIFIED, POUND, KILOGRAM)
def fromValue(__value: _root_.scala.Int): WeightUnit = __value match {
case 0 => WEIGHT_UNIT_UNSPECIFIED
case 1 => POUND
case 2 => KILOGRAM
case __other => Unrecognized(__other)
}
def javaDescriptor: _root_.com.google.protobuf.Descriptors.EnumDescriptor = fs2.pubsub.grpc.internal.Weight.javaDescriptor.getEnumTypes().get(0)
def scalaDescriptor: _root_.scalapb.descriptors.EnumDescriptor = fs2.pubsub.grpc.internal.Weight.scalaDescriptor.enums(0)
}
implicit class WeightLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, fs2.pubsub.grpc.internal.Weight]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, fs2.pubsub.grpc.internal.Weight](_l) {
def amountMicros: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Long] = field(_.getAmountMicros)((c_, f_) => c_.copy(amountMicros = Option(f_)))
def optionalAmountMicros: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Option[_root_.scala.Long]] = field(_.amountMicros)((c_, f_) => c_.copy(amountMicros = f_))
def unit: _root_.scalapb.lenses.Lens[UpperPB, fs2.pubsub.grpc.internal.Weight.WeightUnit] = field(_.unit)((c_, f_) => c_.copy(unit = f_))
}
final val AMOUNT_MICROS_FIELD_NUMBER = 1
final val UNIT_FIELD_NUMBER = 2
def of(
amountMicros: _root_.scala.Option[_root_.scala.Long],
unit: fs2.pubsub.grpc.internal.Weight.WeightUnit
): _root_.fs2.pubsub.grpc.internal.Weight = _root_.fs2.pubsub.grpc.internal.Weight(
amountMicros,
unit
)
// @@protoc_insertion_point(GeneratedMessageCompanion[google.shopping.type.Weight])
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy