Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Generated by Scrooge
* version: 20.4.1
* rev: 74d6bed636c90dc4b67e342ecd80033bad43e94d
* built at: 20200425-214521
*/
package com.twitter.finagle.thrift.thriftscala
import com.twitter.io.Buf
import com.twitter.scrooge.{
InvalidFieldsException,
LazyTProtocol,
StructBuilder,
StructBuilderFactory,
TFieldBlob,
ThriftStruct,
ThriftStructCodec3,
ThriftStructField,
ThriftStructFieldInfo,
ThriftStructMetaData,
ValidatingThriftStruct,
ValidatingThriftStructCodec3
}
import org.apache.thrift.protocol._
import org.apache.thrift.transport.TMemoryBuffer
import scala.collection.immutable.{Map => immutable$Map}
import scala.collection.mutable.Builder
import scala.reflect.{ClassTag, classTag}
/**
* Indicates the network context of a service recording an annotation with two
* exceptions.
*
* When a BinaryAnnotation, and key is CLIENT_ADDR or SERVER_ADDR,
* the endpoint indicates the source or destination of an RPC. This exception
* allows zipkin to display network context of uninstrumented services, or
* clients such as web browsers.
*/
object Endpoint extends ValidatingThriftStructCodec3[Endpoint] with StructBuilderFactory[Endpoint] {
val NoPassthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty[Short, TFieldBlob]
val Struct: TStruct = new TStruct("Endpoint")
val Ipv4Field: TField = new TField("ipv4", TType.I32, 1)
val Ipv4FieldManifest: Manifest[Int] = manifest[Int]
val PortField: TField = new TField("port", TType.I16, 2)
val PortFieldManifest: Manifest[Short] = manifest[Short]
val ServiceNameField: TField = new TField("service_name", TType.STRING, 3)
val ServiceNameFieldManifest: Manifest[String] = manifest[String]
/**
* Field information in declaration order.
*/
lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo](
new ThriftStructFieldInfo(
Ipv4Field,
false,
false,
Ipv4FieldManifest,
_root_.scala.None,
_root_.scala.None,
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
),
new ThriftStructFieldInfo(
PortField,
false,
false,
PortFieldManifest,
_root_.scala.None,
_root_.scala.None,
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
),
new ThriftStructFieldInfo(
ServiceNameField,
false,
false,
ServiceNameFieldManifest,
_root_.scala.None,
_root_.scala.None,
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
)
)
val structAnnotations: immutable$Map[String, String] =
immutable$Map.empty[String, String]
private val fieldTypes: IndexedSeq[ClassTag[_]] = IndexedSeq[ClassTag[_]](
classTag[Int].asInstanceOf[ClassTag[_]],
classTag[Short].asInstanceOf[ClassTag[_]],
classTag[String].asInstanceOf[ClassTag[_]]
)
private[this] val structFields: Seq[ThriftStructField[Endpoint]] = Seq[ThriftStructField[Endpoint]](
new ThriftStructField[Endpoint](
Ipv4Field,
_root_.scala.Some(Ipv4FieldManifest),
classOf[Endpoint]) {
def getValue[R](struct: Endpoint): R = struct.ipv4.asInstanceOf[R]
},
new ThriftStructField[Endpoint](
PortField,
_root_.scala.Some(PortFieldManifest),
classOf[Endpoint]) {
def getValue[R](struct: Endpoint): R = struct.port.asInstanceOf[R]
},
new ThriftStructField[Endpoint](
ServiceNameField,
_root_.scala.Some(ServiceNameFieldManifest),
classOf[Endpoint]) {
def getValue[R](struct: Endpoint): R = struct.serviceName.asInstanceOf[R]
}
)
override lazy val metaData: ThriftStructMetaData[Endpoint] =
new ThriftStructMetaData(this, structFields, fieldInfos, Nil, structAnnotations)
/**
* Checks that all required fields are non-null.
*/
def validate(_item: Endpoint): Unit = {
}
/**
* Checks that the struct is a valid as a new instance. If there are any missing required or
* construction required fields, return a non-empty list.
*/
def validateNewInstance(item: Endpoint): scala.Seq[com.twitter.scrooge.validation.Issue] = {
val buf = scala.collection.mutable.ListBuffer.empty[com.twitter.scrooge.validation.Issue]
buf ++= validateField(item.ipv4)
buf ++= validateField(item.port)
buf ++= validateField(item.serviceName)
buf.toList
}
def withoutPassthroughFields(original: Endpoint): Endpoint =
new Immutable(
ipv4 = original.ipv4,
port = original.port,
serviceName = original.serviceName
)
def newBuilder(): StructBuilder[Endpoint] = new EndpointStructBuilder(_root_.scala.None, fieldTypes)
override def encode(_item: Endpoint, _oproto: TProtocol): Unit = {
_item.write(_oproto)
}
private[this] def lazyDecode(_iprot: LazyTProtocol): Endpoint = {
var ipv4: Int = 0
var port: Short = 0
var service_nameOffset: Int = -1
var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null
var _done = false
val _start_offset = _iprot.offset
_iprot.readStructBegin()
do {
val _field = _iprot.readFieldBegin()
val _fieldType = _field.`type`
if (_fieldType == TType.STOP) {
_done = true
} else {
_field.id match {
case 1 =>
if (_fieldType == TType.I32) {
ipv4 = readIpv4Value(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'ipv4' (expected=%s, actual=%s).",
TType.I32,
_fieldType
)
}
case 2 =>
if (_fieldType == TType.I16) {
port = readPortValue(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'port' (expected=%s, actual=%s).",
TType.I16,
_fieldType
)
}
case 3 =>
if (_fieldType == TType.STRING) {
service_nameOffset = _iprot.offsetSkipString()
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'serviceName' (expected=%s, actual=%s).",
TType.STRING,
_fieldType
)
}
case _ =>
if (_passthroughFields eq null)
_passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob]
_passthroughFields += _root_.scala.Tuple2(_field.id, TFieldBlob.read(_field, _iprot))
}
_iprot.readFieldEnd()
}
} while (!_done)
_iprot.readStructEnd()
new LazyImmutable(
_iprot,
_iprot.buffer,
_start_offset,
_iprot.offset,
ipv4,
port,
service_nameOffset,
if (_passthroughFields eq null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
override def decode(_iprot: TProtocol): Endpoint = {
if (_iprot.isInstanceOf[LazyTProtocol]) {
lazyDecode(_iprot.asInstanceOf[LazyTProtocol])
} else {
eagerDecode(_iprot)
}
}
private[thriftscala] def eagerDecode(_iprot: TProtocol): Endpoint = {
var ipv4: Int = 0
var port: Short = 0
var serviceName: String = null
var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null
var _done = false
_iprot.readStructBegin()
do {
val _field = _iprot.readFieldBegin()
val _fieldType = _field.`type`
if (_fieldType == TType.STOP) {
_done = true
} else {
_field.id match {
case 1 =>
if (_fieldType == TType.I32) {
ipv4 = readIpv4Value(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'ipv4' (expected=%s, actual=%s).",
TType.I32,
_fieldType
)
}
case 2 =>
if (_fieldType == TType.I16) {
port = readPortValue(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'port' (expected=%s, actual=%s).",
TType.I16,
_fieldType
)
}
case 3 =>
if (_fieldType == TType.STRING) {
serviceName = readServiceNameValue(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'serviceName' (expected=%s, actual=%s).",
TType.STRING,
_fieldType
)
}
case _ =>
if (_passthroughFields eq null)
_passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob]
_passthroughFields += _root_.scala.Tuple2(_field.id, TFieldBlob.read(_field, _iprot))
}
_iprot.readFieldEnd()
}
} while (!_done)
_iprot.readStructEnd()
new Immutable(
ipv4,
port,
serviceName,
if (_passthroughFields eq null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
def apply(
ipv4: Int,
port: Short,
serviceName: String
): Endpoint =
new Immutable(
ipv4,
port,
serviceName
)
def unapply(_item: Endpoint): _root_.scala.Option[_root_.scala.Tuple3[Int, Short, String]] = _root_.scala.Some(_item.toTuple)
@inline private[thriftscala] def readIpv4Value(_iprot: TProtocol): Int = {
_iprot.readI32()
}
@inline private def writeIpv4Field(ipv4_item: Int, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(Ipv4Field)
writeIpv4Value(ipv4_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeIpv4Value(ipv4_item: Int, _oprot: TProtocol): Unit = {
_oprot.writeI32(ipv4_item)
}
@inline private[thriftscala] def readPortValue(_iprot: TProtocol): Short = {
_iprot.readI16()
}
@inline private def writePortField(port_item: Short, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(PortField)
writePortValue(port_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writePortValue(port_item: Short, _oprot: TProtocol): Unit = {
_oprot.writeI16(port_item)
}
@inline private[thriftscala] def readServiceNameValue(_iprot: TProtocol): String = {
_iprot.readString()
}
@inline private def writeServiceNameField(serviceName_item: String, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(ServiceNameField)
writeServiceNameValue(serviceName_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeServiceNameValue(serviceName_item: String, _oprot: TProtocol): Unit = {
_oprot.writeString(serviceName_item)
}
object Immutable extends ThriftStructCodec3[Endpoint] {
override def encode(_item: Endpoint, _oproto: TProtocol): Unit = { _item.write(_oproto) }
override def decode(_iprot: TProtocol): Endpoint = Endpoint.decode(_iprot)
override lazy val metaData: ThriftStructMetaData[Endpoint] = Endpoint.metaData
}
/**
* The default read-only implementation of Endpoint. You typically should not need to
* directly reference this class; instead, use the Endpoint.apply method to construct
* new instances.
*/
class Immutable(
val ipv4: Int,
val port: Short,
val serviceName: String,
override val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends Endpoint {
def this(
ipv4: Int,
port: Short,
serviceName: String
) = this(
ipv4,
port,
serviceName,
immutable$Map.empty[Short, TFieldBlob]
)
}
/**
* This is another Immutable, this however keeps strings as lazy values that are lazily decoded from the backing
* array byte on read.
*/
private[this] class LazyImmutable(
_proto: LazyTProtocol,
_buf: Array[Byte],
_start_offset: Int,
_end_offset: Int,
val ipv4: Int,
val port: Short,
service_nameOffset: Int,
override val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends Endpoint {
override def write(_oprot: TProtocol): Unit = {
if (_oprot.isInstanceOf[LazyTProtocol]) {
_oprot.asInstanceOf[LazyTProtocol].writeRaw(_buf, _start_offset, _end_offset - _start_offset)
} else {
super.write(_oprot)
}
}
lazy val serviceName: String =
if (service_nameOffset == -1)
null
else {
_proto.decodeString(_buf, service_nameOffset)
}
/**
* Override the super hash code to make it a lazy val rather than def.
*
* Calculating the hash code can be expensive, caching it where possible
* can provide significant performance wins. (Key in a hash map for instance)
* Usually not safe since the normal constructor will accept a mutable map or
* set as an arg
* Here however we control how the class is generated from serialized data.
* With the class private and the contract that we throw away our mutable references
* having the hash code lazy here is safe.
*/
override lazy val hashCode: Int = super.hashCode
}
/**
* This Proxy trait allows you to extend the Endpoint trait with additional state or
* behavior and implement the read-only methods from Endpoint using an underlying
* instance.
*/
trait Proxy extends Endpoint {
protected def _underlying_Endpoint: Endpoint
override def ipv4: Int = _underlying_Endpoint.ipv4
override def port: Short = _underlying_Endpoint.port
override def serviceName: String = _underlying_Endpoint.serviceName
override def _passthroughFields: immutable$Map[Short, TFieldBlob] = _underlying_Endpoint._passthroughFields
}
}
/**
* Prefer the companion object's [[com.twitter.finagle.thrift.thriftscala.Endpoint.apply]]
* for construction if you don't need to specify passthrough fields.
*/
trait Endpoint
extends ThriftStruct
with _root_.scala.Product3[Int, Short, String]
with ValidatingThriftStruct[Endpoint]
with java.io.Serializable
{
import Endpoint._
def ipv4: Int
def port: Short
def serviceName: String
def _passthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty
def _1: Int = ipv4
def _2: Short = port
def _3: String = serviceName
def toTuple: _root_.scala.Tuple3[Int, Short, String] =
_root_.scala.Tuple3[Int, Short, String](
ipv4,
port,
serviceName
)
/**
* Gets a field value encoded as a binary blob using TCompactProtocol. If the specified field
* is present in the passthrough map, that value is returned. Otherwise, if the specified field
* is known and not optional and set to None, then the field is serialized and returned.
*/
def getFieldBlob(_fieldId: Short): _root_.scala.Option[TFieldBlob] = {
val passedthroughValue = _passthroughFields.get(_fieldId)
if (passedthroughValue.isDefined) {
passedthroughValue
} else {
val _buff = new TMemoryBuffer(32)
val _oprot = new TCompactProtocol(_buff)
val _fieldOpt: _root_.scala.Option[TField] = _fieldId match {
case 1 =>
writeIpv4Value(ipv4, _oprot)
_root_.scala.Some(Endpoint.Ipv4Field)
case 2 =>
writePortValue(port, _oprot)
_root_.scala.Some(Endpoint.PortField)
case 3 =>
if (serviceName ne null) {
writeServiceNameValue(serviceName, _oprot)
_root_.scala.Some(Endpoint.ServiceNameField)
} else {
_root_.scala.None
}
case _ => _root_.scala.None
}
if (_fieldOpt.isDefined) {
_root_.scala.Some(TFieldBlob(_fieldOpt.get, Buf.ByteArray.Owned(_buff.getArray)))
} else {
_root_.scala.None
}
}
}
/**
* Collects TCompactProtocol-encoded field values according to `getFieldBlob` into a map.
*/
def getFieldBlobs(ids: TraversableOnce[Short]): immutable$Map[Short, TFieldBlob] =
(ids.flatMap { id => getFieldBlob(id).map { fieldBlob => (id, fieldBlob) } }).toMap
/**
* Sets a field using a TCompactProtocol-encoded binary blob. If the field is a known
* field, the blob is decoded and the field is set to the decoded value. If the field
* is unknown and passthrough fields are enabled, then the blob will be stored in
* _passthroughFields.
*/
def setField(_blob: TFieldBlob): Endpoint = {
var ipv4: Int = this.ipv4
var port: Short = this.port
var serviceName: String = this.serviceName
var _passthroughFields = this._passthroughFields
_blob.id match {
case 1 =>
ipv4 = readIpv4Value(_blob.read)
case 2 =>
port = readPortValue(_blob.read)
case 3 =>
serviceName = readServiceNameValue(_blob.read)
case _ => _passthroughFields += _root_.scala.Tuple2(_blob.id, _blob)
}
new Immutable(
ipv4,
port,
serviceName,
_passthroughFields
)
}
/**
* If the specified field is optional, it is set to None. Otherwise, if the field is
* known, it is reverted to its default value; if the field is unknown, it is removed
* from the passthroughFields map, if present.
*/
def unsetField(_fieldId: Short): Endpoint = {
var ipv4: Int = this.ipv4
var port: Short = this.port
var serviceName: String = this.serviceName
_fieldId match {
case 1 =>
ipv4 = 0
case 2 =>
port = 0
case 3 =>
serviceName = null
case _ =>
}
new Immutable(
ipv4,
port,
serviceName,
_passthroughFields - _fieldId
)
}
/**
* If the specified field is optional, it is set to None. Otherwise, if the field is
* known, it is reverted to its default value; if the field is unknown, it is removed
* from the passthroughFields map, if present.
*/
def unsetIpv4: Endpoint = unsetField(1)
def unsetPort: Endpoint = unsetField(2)
def unsetServiceName: Endpoint = unsetField(3)
override def write(_oprot: TProtocol): Unit = {
Endpoint.validate(this)
_oprot.writeStructBegin(Struct)
writeIpv4Field(ipv4, _oprot)
writePortField(port, _oprot)
if (serviceName ne null) writeServiceNameField(serviceName, _oprot)
if (_passthroughFields.nonEmpty) {
_passthroughFields.values.foreach { _.write(_oprot) }
}
_oprot.writeFieldStop()
_oprot.writeStructEnd()
}
def copy(
ipv4: Int = this.ipv4,
port: Short = this.port,
serviceName: String = this.serviceName,
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
): Endpoint =
new Immutable(
ipv4,
port,
serviceName,
_passthroughFields
)
override def canEqual(other: Any): Boolean = other.isInstanceOf[Endpoint]
private[this] def _equals(other: Endpoint): Boolean =
this.productArity == other.productArity &&
this.productIterator.sameElements(other.productIterator) &&
this._passthroughFields == other._passthroughFields
override def equals(other: Any): Boolean =
canEqual(other) && _equals(other.asInstanceOf[Endpoint])
override def hashCode: Int = {
_root_.scala.runtime.ScalaRunTime._hashCode(this)
}
override def toString: String = _root_.scala.runtime.ScalaRunTime._toString(this)
override def productPrefix: String = "Endpoint"
def _codec: ValidatingThriftStructCodec3[Endpoint] = Endpoint
def newBuilder(): StructBuilder[Endpoint] = new EndpointStructBuilder(_root_.scala.Some(this), fieldTypes)
}
private[thriftscala] class EndpointStructBuilder(instance: _root_.scala.Option[Endpoint], fieldTypes: IndexedSeq[ClassTag[_]])
extends StructBuilder[Endpoint](fieldTypes) {
def build(): Endpoint = {
val _fieldArray = fieldArray // shadow variable
if (instance.isDefined) {
val instanceValue = instance.get
Endpoint(
if (_fieldArray(0) == null) instanceValue.ipv4 else _fieldArray(0).asInstanceOf[Int],
if (_fieldArray(1) == null) instanceValue.port else _fieldArray(1).asInstanceOf[Short],
if (_fieldArray(2) == null) instanceValue.serviceName else _fieldArray(2).asInstanceOf[String]
)
} else {
if (genericArrayOps(_fieldArray).contains(null)) throw new InvalidFieldsException(structBuildError("Endpoint"))
Endpoint(
_fieldArray(0).asInstanceOf[Int],
_fieldArray(1).asInstanceOf[Short],
_fieldArray(2).asInstanceOf[String]
)
}
}
}