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}
/**
* The Response carries a reply header for tracing. These are
* empty unless the request is being debugged, in which case a
* transcript is copied.
*/
object ResponseHeader extends ValidatingThriftStructCodec3[ResponseHeader] with StructBuilderFactory[ResponseHeader] {
val NoPassthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty[Short, TFieldBlob]
val Struct: TStruct = new TStruct("ResponseHeader")
val SpansField: TField = new TField("spans", TType.LIST, 1)
val SpansFieldManifest: Manifest[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span]] = manifest[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span]]
val ContextsField: TField = new TField("contexts", TType.LIST, 2)
val ContextsFieldManifest: Manifest[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext]] = manifest[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext]]
/**
* Field information in declaration order.
*/
lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo](
new ThriftStructFieldInfo(
SpansField,
false,
false,
SpansFieldManifest,
_root_.scala.None,
_root_.scala.Some(manifest[com.twitter.finagle.thrift.thriftscala.Span]),
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
),
new ThriftStructFieldInfo(
ContextsField,
false,
false,
ContextsFieldManifest,
_root_.scala.None,
_root_.scala.Some(manifest[com.twitter.finagle.thrift.thriftscala.RequestContext]),
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[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span]].asInstanceOf[ClassTag[_]],
classTag[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext]].asInstanceOf[ClassTag[_]]
)
private[this] val structFields: Seq[ThriftStructField[ResponseHeader]] = Seq[ThriftStructField[ResponseHeader]](
new ThriftStructField[ResponseHeader](
SpansField,
_root_.scala.Some(SpansFieldManifest),
classOf[ResponseHeader]) {
def getValue[R](struct: ResponseHeader): R = struct.spans.asInstanceOf[R]
},
new ThriftStructField[ResponseHeader](
ContextsField,
_root_.scala.Some(ContextsFieldManifest),
classOf[ResponseHeader]) {
def getValue[R](struct: ResponseHeader): R = struct.contexts.asInstanceOf[R]
}
)
override lazy val metaData: ThriftStructMetaData[ResponseHeader] =
new ThriftStructMetaData(this, structFields, fieldInfos, Nil, structAnnotations)
/**
* Checks that all required fields are non-null.
*/
def validate(_item: ResponseHeader): 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: ResponseHeader): scala.Seq[com.twitter.scrooge.validation.Issue] = {
val buf = scala.collection.mutable.ListBuffer.empty[com.twitter.scrooge.validation.Issue]
buf ++= validateField(item.spans)
buf ++= validateField(item.contexts)
buf.toList
}
def withoutPassthroughFields(original: ResponseHeader): ResponseHeader =
new Immutable(
spans =
{
val field = original.spans
field.map { field =>
com.twitter.finagle.thrift.thriftscala.Span.withoutPassthroughFields(field)
}
},
contexts =
{
val field = original.contexts
field.map { field =>
com.twitter.finagle.thrift.thriftscala.RequestContext.withoutPassthroughFields(field)
}
}
)
def newBuilder(): StructBuilder[ResponseHeader] = new ResponseHeaderStructBuilder(_root_.scala.None, fieldTypes)
override def encode(_item: ResponseHeader, _oproto: TProtocol): Unit = {
_item.write(_oproto)
}
private[this] def lazyDecode(_iprot: LazyTProtocol): ResponseHeader = {
var spans: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span] = _root_.scala.collection.immutable.Nil
var contexts: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext] = _root_.scala.collection.immutable.Nil
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.LIST) {
spans = readSpansValue(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'spans' (expected=%s, actual=%s).",
TType.LIST,
_fieldType
)
}
case 2 =>
if (_fieldType == TType.LIST) {
contexts = readContextsValue(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'contexts' (expected=%s, actual=%s).",
TType.LIST,
_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,
spans,
contexts,
if (_passthroughFields eq null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
override def decode(_iprot: TProtocol): ResponseHeader = {
if (_iprot.isInstanceOf[LazyTProtocol]) {
lazyDecode(_iprot.asInstanceOf[LazyTProtocol])
} else {
eagerDecode(_iprot)
}
}
private[thriftscala] def eagerDecode(_iprot: TProtocol): ResponseHeader = {
var spans: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span] = _root_.scala.collection.immutable.Nil
var contexts: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext] = _root_.scala.collection.immutable.Nil
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.LIST) {
spans = readSpansValue(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'spans' (expected=%s, actual=%s).",
TType.LIST,
_fieldType
)
}
case 2 =>
if (_fieldType == TType.LIST) {
contexts = readContextsValue(_iprot)
} else {
_root_.com.twitter.scrooge.internal.ApplicationExceptions.throwWrongFieldTypeException(
"Received wrong type for field 'contexts' (expected=%s, actual=%s).",
TType.LIST,
_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(
spans,
contexts,
if (_passthroughFields eq null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
def apply(
spans: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span] = _root_.scala.collection.immutable.Nil,
contexts: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext] = _root_.scala.collection.immutable.Nil
): ResponseHeader =
new Immutable(
spans,
contexts
)
def unapply(_item: ResponseHeader): _root_.scala.Option[_root_.scala.Tuple2[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext]]] = _root_.scala.Some(_item.toTuple)
@inline private[thriftscala] def readSpansValue(_iprot: TProtocol): _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span] = {
val _list = _iprot.readListBegin()
if (_list.size == 0) {
_iprot.readListEnd()
Nil
} else {
val _rv = new _root_.scala.collection.mutable.ArrayBuffer[com.twitter.finagle.thrift.thriftscala.Span](_list.size)
var _i = 0
do {
_rv += {
com.twitter.finagle.thrift.thriftscala.Span.decode(_iprot)
}
_i += 1
} while (_i < _list.size)
_iprot.readListEnd()
_rv
}
}
@inline private def writeSpansField(spans_item: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span], _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(SpansField)
writeSpansValue(spans_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeSpansValue(spans_item: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span], _oprot: TProtocol): Unit = {
_oprot.writeListBegin(new TList(TType.STRUCT, spans_item.size))
if (spans_item.isInstanceOf[IndexedSeq[_]]) {
var _i = 0
val _size = spans_item.size
while (_i < _size) {
val spans_item_element = spans_item(_i)
spans_item_element.write(_oprot)
_i += 1
}
} else {
spans_item.foreach { spans_item_element =>
spans_item_element.write(_oprot)
}
}
_oprot.writeListEnd()
}
@inline private[thriftscala] def readContextsValue(_iprot: TProtocol): _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext] = {
val _list = _iprot.readListBegin()
if (_list.size == 0) {
_iprot.readListEnd()
Nil
} else {
val _rv = new _root_.scala.collection.mutable.ArrayBuffer[com.twitter.finagle.thrift.thriftscala.RequestContext](_list.size)
var _i = 0
do {
_rv += {
com.twitter.finagle.thrift.thriftscala.RequestContext.decode(_iprot)
}
_i += 1
} while (_i < _list.size)
_iprot.readListEnd()
_rv
}
}
@inline private def writeContextsField(contexts_item: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext], _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(ContextsField)
writeContextsValue(contexts_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeContextsValue(contexts_item: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext], _oprot: TProtocol): Unit = {
_oprot.writeListBegin(new TList(TType.STRUCT, contexts_item.size))
if (contexts_item.isInstanceOf[IndexedSeq[_]]) {
var _i = 0
val _size = contexts_item.size
while (_i < _size) {
val contexts_item_element = contexts_item(_i)
contexts_item_element.write(_oprot)
_i += 1
}
} else {
contexts_item.foreach { contexts_item_element =>
contexts_item_element.write(_oprot)
}
}
_oprot.writeListEnd()
}
object Immutable extends ThriftStructCodec3[ResponseHeader] {
override def encode(_item: ResponseHeader, _oproto: TProtocol): Unit = { _item.write(_oproto) }
override def decode(_iprot: TProtocol): ResponseHeader = ResponseHeader.decode(_iprot)
override lazy val metaData: ThriftStructMetaData[ResponseHeader] = ResponseHeader.metaData
}
/**
* The default read-only implementation of ResponseHeader. You typically should not need to
* directly reference this class; instead, use the ResponseHeader.apply method to construct
* new instances.
*/
class Immutable(
val spans: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span],
val contexts: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext],
override val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ResponseHeader {
def this(
spans: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span] = _root_.scala.collection.immutable.Nil,
contexts: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext] = _root_.scala.collection.immutable.Nil
) = this(
spans,
contexts,
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 spans: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span],
val contexts: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext],
override val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ResponseHeader {
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)
}
}
/**
* 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 ResponseHeader trait with additional state or
* behavior and implement the read-only methods from ResponseHeader using an underlying
* instance.
*/
trait Proxy extends ResponseHeader {
protected def _underlying_ResponseHeader: ResponseHeader
override def spans: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span] = _underlying_ResponseHeader.spans
override def contexts: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext] = _underlying_ResponseHeader.contexts
override def _passthroughFields: immutable$Map[Short, TFieldBlob] = _underlying_ResponseHeader._passthroughFields
}
}
/**
* Prefer the companion object's [[com.twitter.finagle.thrift.thriftscala.ResponseHeader.apply]]
* for construction if you don't need to specify passthrough fields.
*/
trait ResponseHeader
extends ThriftStruct
with _root_.scala.Product2[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext]]
with ValidatingThriftStruct[ResponseHeader]
with java.io.Serializable
{
import ResponseHeader._
def spans: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span]
def contexts: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext]
def _passthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty
def _1: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span] = spans
def _2: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext] = contexts
def toTuple: _root_.scala.Tuple2[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext]] =
_root_.scala.Tuple2[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span], _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext]](
spans,
contexts
)
/**
* 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 =>
if (spans ne null) {
writeSpansValue(spans, _oprot)
_root_.scala.Some(ResponseHeader.SpansField)
} else {
_root_.scala.None
}
case 2 =>
if (contexts ne null) {
writeContextsValue(contexts, _oprot)
_root_.scala.Some(ResponseHeader.ContextsField)
} 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): ResponseHeader = {
var spans: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span] = this.spans
var contexts: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext] = this.contexts
var _passthroughFields = this._passthroughFields
_blob.id match {
case 1 =>
spans = readSpansValue(_blob.read)
case 2 =>
contexts = readContextsValue(_blob.read)
case _ => _passthroughFields += _root_.scala.Tuple2(_blob.id, _blob)
}
new Immutable(
spans,
contexts,
_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): ResponseHeader = {
var spans: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span] = this.spans
var contexts: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext] = this.contexts
_fieldId match {
case 1 =>
spans = _root_.scala.collection.immutable.Nil
case 2 =>
contexts = _root_.scala.collection.immutable.Nil
case _ =>
}
new Immutable(
spans,
contexts,
_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 unsetSpans: ResponseHeader = unsetField(1)
def unsetContexts: ResponseHeader = unsetField(2)
override def write(_oprot: TProtocol): Unit = {
ResponseHeader.validate(this)
_oprot.writeStructBegin(Struct)
if (spans ne null) writeSpansField(spans, _oprot)
if (contexts ne null) writeContextsField(contexts, _oprot)
if (_passthroughFields.nonEmpty) {
_passthroughFields.values.foreach { _.write(_oprot) }
}
_oprot.writeFieldStop()
_oprot.writeStructEnd()
}
def copy(
spans: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span] = this.spans,
contexts: _root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext] = this.contexts,
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
): ResponseHeader =
new Immutable(
spans,
contexts,
_passthroughFields
)
override def canEqual(other: Any): Boolean = other.isInstanceOf[ResponseHeader]
private[this] def _equals(other: ResponseHeader): 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[ResponseHeader])
override def hashCode: Int = {
_root_.scala.runtime.ScalaRunTime._hashCode(this)
}
override def toString: String = _root_.scala.runtime.ScalaRunTime._toString(this)
override def productPrefix: String = "ResponseHeader"
def _codec: ValidatingThriftStructCodec3[ResponseHeader] = ResponseHeader
def newBuilder(): StructBuilder[ResponseHeader] = new ResponseHeaderStructBuilder(_root_.scala.Some(this), fieldTypes)
}
private[thriftscala] class ResponseHeaderStructBuilder(instance: _root_.scala.Option[ResponseHeader], fieldTypes: IndexedSeq[ClassTag[_]])
extends StructBuilder[ResponseHeader](fieldTypes) {
def build(): ResponseHeader = {
val _fieldArray = fieldArray // shadow variable
if (instance.isDefined) {
val instanceValue = instance.get
ResponseHeader(
if (_fieldArray(0) == null) instanceValue.spans else _fieldArray(0).asInstanceOf[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span]],
if (_fieldArray(1) == null) instanceValue.contexts else _fieldArray(1).asInstanceOf[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext]]
)
} else {
if (genericArrayOps(_fieldArray).contains(null)) throw new InvalidFieldsException(structBuildError("ResponseHeader"))
ResponseHeader(
_fieldArray(0).asInstanceOf[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.Span]],
_fieldArray(1).asInstanceOf[_root_.scala.collection.Seq[com.twitter.finagle.thrift.thriftscala.RequestContext]]
)
}
}
}