scray.service.qservice.thrifscala.ScrayTServiceEndpoint.scala Maven / Gradle / Ivy
/**
* Generated by Scrooge
* version: 4.16.0
* rev: 0201cac9fdd6188248d42da91fd14c87744cc4a5
* built at: 20170421-124523
*/
package scray.service.qservice.thrifscala
import com.twitter.scrooge.{
HasThriftStructCodec3,
LazyTProtocol,
TFieldBlob,
ThriftException,
ThriftStruct,
ThriftStructCodec3,
ThriftStructFieldInfo,
ThriftStructMetaData,
ThriftUtil
}
import org.apache.thrift.protocol._
import org.apache.thrift.transport.{TMemoryBuffer, TTransport}
import java.nio.ByteBuffer
import java.util.Arrays
import scala.collection.immutable.{Map => immutable$Map}
import scala.collection.mutable.Builder
import scala.collection.mutable.{
ArrayBuffer => mutable$ArrayBuffer, Buffer => mutable$Buffer,
HashMap => mutable$HashMap, HashSet => mutable$HashSet}
import scala.collection.{Map, Set}
/**
* Scray service endpoint
*/
object ScrayTServiceEndpoint extends ThriftStructCodec3[ScrayTServiceEndpoint] {
private val NoPassthroughFields = immutable$Map.empty[Short, TFieldBlob]
val Struct = new TStruct("ScrayTServiceEndpoint")
val HostField = new TField("host", TType.STRING, 1)
val HostFieldManifest = implicitly[Manifest[String]]
val PortField = new TField("port", TType.I32, 2)
val PortFieldManifest = implicitly[Manifest[Int]]
val EndpointIdField = new TField("endpointId", TType.STRUCT, 3)
val EndpointIdFieldManifest = implicitly[Manifest[scray.service.qmodel.thrifscala.ScrayUUID]]
val ExpiresField = new TField("expires", TType.I64, 4)
val ExpiresFieldManifest = implicitly[Manifest[Long]]
/**
* Field information in declaration order.
*/
lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo](
new ThriftStructFieldInfo(
HostField,
false,
false,
HostFieldManifest,
_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(
EndpointIdField,
true,
false,
EndpointIdFieldManifest,
_root_.scala.None,
_root_.scala.None,
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
),
new ThriftStructFieldInfo(
ExpiresField,
true,
false,
ExpiresFieldManifest,
_root_.scala.None,
_root_.scala.None,
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
)
)
lazy val structAnnotations: immutable$Map[String, String] =
immutable$Map.empty[String, String]
/**
* Checks that all required fields are non-null.
*/
def validate(_item: ScrayTServiceEndpoint): Unit = {
}
def withoutPassthroughFields(original: ScrayTServiceEndpoint): ScrayTServiceEndpoint =
new Immutable(
host =
{
val field = original.host
field
},
port =
{
val field = original.port
field
},
endpointId =
{
val field = original.endpointId
field.map { field =>
scray.service.qmodel.thrifscala.ScrayUUID.withoutPassthroughFields(field)
}
},
expires =
{
val field = original.expires
field.map { field =>
field
}
}
)
override def encode(_item: ScrayTServiceEndpoint, _oproto: TProtocol): Unit = {
_item.write(_oproto)
}
private[this] def lazyDecode(_iprot: LazyTProtocol): ScrayTServiceEndpoint = {
var hostOffset: Int = -1
var port: Int = 0
var endpointId: Option[scray.service.qmodel.thrifscala.ScrayUUID] = None
var expiresOffset: Int = -1
var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null
var _done = false
val _start_offset = _iprot.offset
_iprot.readStructBegin()
while (!_done) {
val _field = _iprot.readFieldBegin()
if (_field.`type` == TType.STOP) {
_done = true
} else {
_field.id match {
case 1 =>
_field.`type` match {
case TType.STRING =>
hostOffset = _iprot.offsetSkipString
case _actualType =>
val _expectedType = TType.STRING
throw new TProtocolException(
"Received wrong type for field 'host' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case 2 =>
_field.`type` match {
case TType.I32 =>
port = readPortValue(_iprot)
case _actualType =>
val _expectedType = TType.I32
throw new TProtocolException(
"Received wrong type for field 'port' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case 3 =>
_field.`type` match {
case TType.STRUCT =>
endpointId = Some(readEndpointIdValue(_iprot))
case _actualType =>
val _expectedType = TType.STRUCT
throw new TProtocolException(
"Received wrong type for field 'endpointId' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case 4 =>
_field.`type` match {
case TType.I64 =>
expiresOffset = _iprot.offsetSkipI64
case _actualType =>
val _expectedType = TType.I64
throw new TProtocolException(
"Received wrong type for field 'expires' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case _ =>
if (_passthroughFields == null)
_passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob]
_passthroughFields += (_field.id -> TFieldBlob.read(_field, _iprot))
}
_iprot.readFieldEnd()
}
}
_iprot.readStructEnd()
new LazyImmutable(
_iprot,
_iprot.buffer,
_start_offset,
_iprot.offset,
hostOffset,
port,
endpointId,
expiresOffset,
if (_passthroughFields == null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
override def decode(_iprot: TProtocol): ScrayTServiceEndpoint =
_iprot match {
case i: LazyTProtocol => lazyDecode(i)
case i => eagerDecode(i)
}
private[this] def eagerDecode(_iprot: TProtocol): ScrayTServiceEndpoint = {
var host: String = null
var port: Int = 0
var endpointId: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID] = _root_.scala.None
var expires: _root_.scala.Option[Long] = _root_.scala.None
var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null
var _done = false
_iprot.readStructBegin()
while (!_done) {
val _field = _iprot.readFieldBegin()
if (_field.`type` == TType.STOP) {
_done = true
} else {
_field.id match {
case 1 =>
_field.`type` match {
case TType.STRING =>
host = readHostValue(_iprot)
case _actualType =>
val _expectedType = TType.STRING
throw new TProtocolException(
"Received wrong type for field 'host' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case 2 =>
_field.`type` match {
case TType.I32 =>
port = readPortValue(_iprot)
case _actualType =>
val _expectedType = TType.I32
throw new TProtocolException(
"Received wrong type for field 'port' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case 3 =>
_field.`type` match {
case TType.STRUCT =>
endpointId = _root_.scala.Some(readEndpointIdValue(_iprot))
case _actualType =>
val _expectedType = TType.STRUCT
throw new TProtocolException(
"Received wrong type for field 'endpointId' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case 4 =>
_field.`type` match {
case TType.I64 =>
expires = _root_.scala.Some(readExpiresValue(_iprot))
case _actualType =>
val _expectedType = TType.I64
throw new TProtocolException(
"Received wrong type for field 'expires' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case _ =>
if (_passthroughFields == null)
_passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob]
_passthroughFields += (_field.id -> TFieldBlob.read(_field, _iprot))
}
_iprot.readFieldEnd()
}
}
_iprot.readStructEnd()
new Immutable(
host,
port,
endpointId,
expires,
if (_passthroughFields == null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
def apply(
host: String,
port: Int,
endpointId: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID] = _root_.scala.None,
expires: _root_.scala.Option[Long] = _root_.scala.None
): ScrayTServiceEndpoint =
new Immutable(
host,
port,
endpointId,
expires
)
def unapply(_item: ScrayTServiceEndpoint): _root_.scala.Option[_root_.scala.Tuple4[String, Int, Option[scray.service.qmodel.thrifscala.ScrayUUID], Option[Long]]] = _root_.scala.Some(_item.toTuple)
@inline private def readHostValue(_iprot: TProtocol): String = {
_iprot.readString()
}
@inline private def writeHostField(host_item: String, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(HostField)
writeHostValue(host_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeHostValue(host_item: String, _oprot: TProtocol): Unit = {
_oprot.writeString(host_item)
}
@inline private def readPortValue(_iprot: TProtocol): Int = {
_iprot.readI32()
}
@inline private def writePortField(port_item: Int, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(PortField)
writePortValue(port_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writePortValue(port_item: Int, _oprot: TProtocol): Unit = {
_oprot.writeI32(port_item)
}
@inline private def readEndpointIdValue(_iprot: TProtocol): scray.service.qmodel.thrifscala.ScrayUUID = {
scray.service.qmodel.thrifscala.ScrayUUID.decode(_iprot)
}
@inline private def writeEndpointIdField(endpointId_item: scray.service.qmodel.thrifscala.ScrayUUID, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(EndpointIdField)
writeEndpointIdValue(endpointId_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeEndpointIdValue(endpointId_item: scray.service.qmodel.thrifscala.ScrayUUID, _oprot: TProtocol): Unit = {
endpointId_item.write(_oprot)
}
@inline private def readExpiresValue(_iprot: TProtocol): Long = {
_iprot.readI64()
}
@inline private def writeExpiresField(expires_item: Long, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(ExpiresField)
writeExpiresValue(expires_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeExpiresValue(expires_item: Long, _oprot: TProtocol): Unit = {
_oprot.writeI64(expires_item)
}
object Immutable extends ThriftStructCodec3[ScrayTServiceEndpoint] {
override def encode(_item: ScrayTServiceEndpoint, _oproto: TProtocol): Unit = { _item.write(_oproto) }
override def decode(_iprot: TProtocol): ScrayTServiceEndpoint = ScrayTServiceEndpoint.decode(_iprot)
override lazy val metaData: ThriftStructMetaData[ScrayTServiceEndpoint] = ScrayTServiceEndpoint.metaData
}
/**
* The default read-only implementation of ScrayTServiceEndpoint. You typically should not need to
* directly reference this class; instead, use the ScrayTServiceEndpoint.apply method to construct
* new instances.
*/
class Immutable(
val host: String,
val port: Int,
val endpointId: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID],
val expires: _root_.scala.Option[Long],
override val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ScrayTServiceEndpoint {
def this(
host: String,
port: Int,
endpointId: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID] = _root_.scala.None,
expires: _root_.scala.Option[Long] = _root_.scala.None
) = this(
host,
port,
endpointId,
expires,
Map.empty
)
}
/**
* 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,
hostOffset: Int,
val port: Int,
val endpointId: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID],
expiresOffset: Int,
override val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ScrayTServiceEndpoint {
override def write(_oprot: TProtocol): Unit = {
_oprot match {
case i: LazyTProtocol => i.writeRaw(_buf, _start_offset, _end_offset - _start_offset)
case _ => super.write(_oprot)
}
}
lazy val host: String =
if (hostOffset == -1)
null
else {
_proto.decodeString(_buf, hostOffset)
}
lazy val expires: _root_.scala.Option[Long] =
if (expiresOffset == -1)
None
else {
Some(_proto.decodeI64(_buf, expiresOffset))
}
/**
* 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 = super.hashCode
}
/**
* This Proxy trait allows you to extend the ScrayTServiceEndpoint trait with additional state or
* behavior and implement the read-only methods from ScrayTServiceEndpoint using an underlying
* instance.
*/
trait Proxy extends ScrayTServiceEndpoint {
protected def _underlying_ScrayTServiceEndpoint: ScrayTServiceEndpoint
override def host: String = _underlying_ScrayTServiceEndpoint.host
override def port: Int = _underlying_ScrayTServiceEndpoint.port
override def endpointId: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID] = _underlying_ScrayTServiceEndpoint.endpointId
override def expires: _root_.scala.Option[Long] = _underlying_ScrayTServiceEndpoint.expires
override def _passthroughFields = _underlying_ScrayTServiceEndpoint._passthroughFields
}
}
trait ScrayTServiceEndpoint
extends ThriftStruct
with _root_.scala.Product4[String, Int, Option[scray.service.qmodel.thrifscala.ScrayUUID], Option[Long]]
with HasThriftStructCodec3[ScrayTServiceEndpoint]
with java.io.Serializable
{
import ScrayTServiceEndpoint._
def host: String
def port: Int
def endpointId: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID]
def expires: _root_.scala.Option[Long]
def _passthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty
def _1 = host
def _2 = port
def _3 = endpointId
def _4 = expires
def toTuple: _root_.scala.Tuple4[String, Int, Option[scray.service.qmodel.thrifscala.ScrayUUID], Option[Long]] = {
(
host,
port,
endpointId,
expires
)
}
/**
* 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] = {
lazy val _buff = new TMemoryBuffer(32)
lazy val _oprot = new TCompactProtocol(_buff)
_passthroughFields.get(_fieldId) match {
case blob: _root_.scala.Some[TFieldBlob] => blob
case _root_.scala.None => {
val _fieldOpt: _root_.scala.Option[TField] =
_fieldId match {
case 1 =>
if (host ne null) {
writeHostValue(host, _oprot)
_root_.scala.Some(ScrayTServiceEndpoint.HostField)
} else {
_root_.scala.None
}
case 2 =>
if (true) {
writePortValue(port, _oprot)
_root_.scala.Some(ScrayTServiceEndpoint.PortField)
} else {
_root_.scala.None
}
case 3 =>
if (endpointId.isDefined) {
writeEndpointIdValue(endpointId.get, _oprot)
_root_.scala.Some(ScrayTServiceEndpoint.EndpointIdField)
} else {
_root_.scala.None
}
case 4 =>
if (expires.isDefined) {
writeExpiresValue(expires.get, _oprot)
_root_.scala.Some(ScrayTServiceEndpoint.ExpiresField)
} else {
_root_.scala.None
}
case _ => _root_.scala.None
}
_fieldOpt match {
case _root_.scala.Some(_field) =>
val _data = Arrays.copyOfRange(_buff.getArray, 0, _buff.length)
_root_.scala.Some(TFieldBlob(_field, _data))
case _root_.scala.None =>
_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 { id -> _ } }).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): ScrayTServiceEndpoint = {
var host: String = this.host
var port: Int = this.port
var endpointId: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID] = this.endpointId
var expires: _root_.scala.Option[Long] = this.expires
var _passthroughFields = this._passthroughFields
_blob.id match {
case 1 =>
host = readHostValue(_blob.read)
case 2 =>
port = readPortValue(_blob.read)
case 3 =>
endpointId = _root_.scala.Some(readEndpointIdValue(_blob.read))
case 4 =>
expires = _root_.scala.Some(readExpiresValue(_blob.read))
case _ => _passthroughFields += (_blob.id -> _blob)
}
new Immutable(
host,
port,
endpointId,
expires,
_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): ScrayTServiceEndpoint = {
var host: String = this.host
var port: Int = this.port
var endpointId: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID] = this.endpointId
var expires: _root_.scala.Option[Long] = this.expires
_fieldId match {
case 1 =>
host = null
case 2 =>
port = 0
case 3 =>
endpointId = _root_.scala.None
case 4 =>
expires = _root_.scala.None
case _ =>
}
new Immutable(
host,
port,
endpointId,
expires,
_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 unsetHost: ScrayTServiceEndpoint = unsetField(1)
def unsetPort: ScrayTServiceEndpoint = unsetField(2)
def unsetEndpointId: ScrayTServiceEndpoint = unsetField(3)
def unsetExpires: ScrayTServiceEndpoint = unsetField(4)
override def write(_oprot: TProtocol): Unit = {
ScrayTServiceEndpoint.validate(this)
_oprot.writeStructBegin(Struct)
if (host ne null) writeHostField(host, _oprot)
writePortField(port, _oprot)
if (endpointId.isDefined) writeEndpointIdField(endpointId.get, _oprot)
if (expires.isDefined) writeExpiresField(expires.get, _oprot)
if (_passthroughFields.nonEmpty) {
_passthroughFields.values.foreach { _.write(_oprot) }
}
_oprot.writeFieldStop()
_oprot.writeStructEnd()
}
def copy(
host: String = this.host,
port: Int = this.port,
endpointId: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID] = this.endpointId,
expires: _root_.scala.Option[Long] = this.expires,
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
): ScrayTServiceEndpoint =
new Immutable(
host,
port,
endpointId,
expires,
_passthroughFields
)
override def canEqual(other: Any): Boolean = other.isInstanceOf[ScrayTServiceEndpoint]
private def _equals(x: ScrayTServiceEndpoint, y: ScrayTServiceEndpoint): Boolean =
x.productArity == y.productArity &&
x.productIterator.sameElements(y.productIterator)
override def equals(other: Any): Boolean =
canEqual(other) &&
_equals(this, other.asInstanceOf[ScrayTServiceEndpoint]) &&
_passthroughFields == other.asInstanceOf[ScrayTServiceEndpoint]._passthroughFields
override def hashCode: Int = _root_.scala.runtime.ScalaRunTime._hashCode(this)
override def toString: String = _root_.scala.runtime.ScalaRunTime._toString(this)
override def productArity: Int = 4
override def productElement(n: Int): Any = n match {
case 0 => this.host
case 1 => this.port
case 2 => this.endpointId
case 3 => this.expires
case _ => throw new IndexOutOfBoundsException(n.toString)
}
override def productPrefix: String = "ScrayTServiceEndpoint"
def _codec: ThriftStructCodec3[ScrayTServiceEndpoint] = ScrayTServiceEndpoint
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy