#
# Autogenerated by Thrift
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#  @generated
#

from __future__ import absolute_import
import sys
from thrift.util.Recursive import fix_spec
from thrift.Thrift import TType, TMessageType, TPriority, TRequestContext, TProcessorEventHandler, TServerInterface, TProcessor, TException, TApplicationException, UnimplementedTypedef
from thrift.protocol.TProtocol import TProtocolException



import pprint
import warnings
from thrift import Thrift
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.protocol import TCompactProtocol
from thrift.protocol import THeaderProtocol
fastproto = None
try:
  from thrift.protocol import fastproto
except ImportError:
  pass

def __EXPAND_THRIFT_SPEC(spec):
    next_id = 0
    for item in spec:
        item_id = item[0]
        if next_id >= 0 and item_id < 0:
            next_id = item_id
        if item_id != next_id:
            for _ in range(next_id, item_id):
                yield None
        yield item
        next_id = item_id + 1

class ThriftEnumWrapper(int):
  def __new__(cls, enum_class, value):
    return super().__new__(cls, value)
  def __init__(self, enum_class, value):    self.enum_class = enum_class
  def __repr__(self):
    return self.enum_class.__name__ + '.' + self.enum_class._VALUES_TO_NAMES[self]

all_structs = []
UTF8STRINGS = bool(0) or sys.version_info.major >= 3

__all__ = ['UTF8STRINGS', 'Fields']

class Fields:
  r"""
  Attributes:
   - injected_field
   - injected_structured_annotation_field
   - injected_unstructured_annotation_field
  """

  thrift_spec = None
  thrift_field_annotations = None
  thrift_struct_annotations = None
  __init__ = None
  @staticmethod
  def isUnion():
    return False

  def read(self, iprot):
    if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
      fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0)
      return
    if (isinstance(iprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
      fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2)
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 100:
        if ftype == TType.STRING:
          self.injected_field = iprot.readString().decode('utf-8') if UTF8STRINGS else iprot.readString()
        else:
          iprot.skip(ftype)
      elif fid == 101:
        if ftype == TType.STRING:
          self.injected_structured_annotation_field = iprot.readString().decode('utf-8') if UTF8STRINGS else iprot.readString()
        else:
          iprot.skip(ftype)
      elif fid == 102:
        if ftype == TType.STRING:
          self.injected_unstructured_annotation_field = iprot.readString().decode('utf-8') if UTF8STRINGS else iprot.readString()
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
      oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
      return
    if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
      oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
      return
    oprot.writeStructBegin('Fields')
    if self.injected_field != None:
      oprot.writeFieldBegin('injected_field', TType.STRING, 100)
      oprot.writeString(self.injected_field.encode('utf-8')) if UTF8STRINGS and not isinstance(self.injected_field, bytes) else oprot.writeString(self.injected_field)
      oprot.writeFieldEnd()
    if self.injected_structured_annotation_field != None:
      oprot.writeFieldBegin('injected_structured_annotation_field', TType.STRING, 101)
      oprot.writeString(self.injected_structured_annotation_field.encode('utf-8')) if UTF8STRINGS and not isinstance(self.injected_structured_annotation_field, bytes) else oprot.writeString(self.injected_structured_annotation_field)
      oprot.writeFieldEnd()
    if self.injected_unstructured_annotation_field != None:
      oprot.writeFieldBegin('injected_unstructured_annotation_field', TType.STRING, 102)
      oprot.writeString(self.injected_unstructured_annotation_field.encode('utf-8')) if UTF8STRINGS and not isinstance(self.injected_unstructured_annotation_field, bytes) else oprot.writeString(self.injected_unstructured_annotation_field)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = []
    padding = ' ' * 4
    if self.injected_field is not None:
      value = pprint.pformat(self.injected_field, indent=0)
      value = padding.join(value.splitlines(True))
      L.append('    injected_field=%s' % (value))
    if self.injected_structured_annotation_field is not None:
      value = pprint.pformat(self.injected_structured_annotation_field, indent=0)
      value = padding.join(value.splitlines(True))
      L.append('    injected_structured_annotation_field=%s' % (value))
    if self.injected_unstructured_annotation_field is not None:
      value = pprint.pformat(self.injected_unstructured_annotation_field, indent=0)
      value = padding.join(value.splitlines(True))
      L.append('    injected_unstructured_annotation_field=%s' % (value))
    return "%s(%s)" % (self.__class__.__name__, "\n" + ",\n".join(L) if L else '')

  def __eq__(self, other):
    if not isinstance(other, self.__class__):
      return False

    return self.__dict__ == other.__dict__ 

  def __ne__(self, other):
    return not (self == other)

  def __dir__(self):
    return (
      'injected_field',
      'injected_structured_annotation_field',
      'injected_unstructured_annotation_field',
    )

  __hash__ = object.__hash__

  def _to_python(self):
    import importlib
    import thrift.python.converter
    python_types = importlib.import_module("foo.thrift_types")
    return thrift.python.converter.to_python_struct(python_types.Fields, self)

  def _to_py3(self):
    import importlib
    import thrift.py3.converter
    py3_types = importlib.import_module("foo.types")
    return thrift.py3.converter.to_py3_struct(py3_types.Fields, self)

  def _to_py_deprecated(self):
    return self

all_structs.append(Fields)
Fields.thrift_spec = tuple(__EXPAND_THRIFT_SPEC((
  (100, TType.STRING, 'injected_field', True, None, 2, ), # 100
  (101, TType.STRING, 'injected_structured_annotation_field', True, None, 1, ), # 101
  (102, TType.STRING, 'injected_unstructured_annotation_field', True, None, 1, ), # 102
)))

Fields.thrift_struct_annotations = {
}
Fields.thrift_field_annotations = {
}

def Fields__init__(self, injected_field=None, injected_structured_annotation_field=None, injected_unstructured_annotation_field=None,):
  self.injected_field = injected_field
  self.injected_structured_annotation_field = injected_structured_annotation_field
  self.injected_unstructured_annotation_field = injected_unstructured_annotation_field

Fields.__init__ = Fields__init__

def Fields__setstate__(self, state):
  state.setdefault('injected_field', None)
  state.setdefault('injected_structured_annotation_field', None)
  state.setdefault('injected_unstructured_annotation_field', None)
  self.__dict__ = state

Fields.__getstate__ = lambda self: self.__dict__.copy()
Fields.__setstate__ = Fields__setstate__

fix_spec(all_structs)
del all_structs
