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

/**
* @generated by Thrift
*/

#import <Foundation/Foundation.h>

#import <thrift/TProtocol.h>
#import <thrift/TApplicationException.h>
#import <thrift/TProtocolException.h>
#import <thrift/TProtocolUtil.h>
#import <thrift/TProcessor.h>
#import <thrift/TObjective-C.h>
#import <thrift/TBase.h>
#import <thrift/TBaseStruct.h>
#import <thrift/TBaseException.h>

#import "transitive.h"

static Foo * ExampleFoo;

@implementation transitiveConstants
+ (void) initialize {
  ExampleFoo = [[Foo alloc] init];
  [ExampleFoo setA:2];

;
}
+ (Foo *) ExampleFoo{
  return ExampleFoo;
}
@end

@implementation Foo

- (instancetype) init
{
  self = [super init];
  self.a = 2;

  return self;
}

- (id) initWithA: (int64_t) a
{
  self = [super init];
  __thrift_a = a;
  __thrift_a_set = YES;
  return self;
}

- (id) initWithCoder: (NSCoder *) decoder
{
  self = [super init];
  if ([decoder containsValueForKey: @"a"])
  {
    __thrift_a = [decoder decodeInt64ForKey: @"a"];
    __thrift_a_set = YES;
  }
  return self;
}

- (void) encodeWithCoder: (NSCoder *) encoder
{
  if (__thrift_a_set)
  {
    [encoder encodeInt64: __thrift_a forKey: @"a"];
  }
}

- (int64_t) a {
  return __thrift_a;
}

- (void) setA: (int64_t) a {
  [self throwExceptionIfImmutable];
  __thrift_a = a;
  __thrift_a_set = YES;
}

- (BOOL) aIsSet {
  return __thrift_a_set;
}

- (void) unsetA {
  __thrift_a_set = NO;
}

- (void) read: (id <TProtocol>) inProtocol
{
  NSString * fieldName;
  int fieldType;
  int fieldID;

  [inProtocol readStructBeginReturningName: NULL];
  while (true)
  {
    [inProtocol readFieldBeginReturningName: &fieldName type: &fieldType fieldID: &fieldID];
    if (fieldType == TType_STOP) { 
      break;
    }
    switch (fieldID)
    {
      case 1:
        if (fieldType == TType_I64) {
          int64_t fieldValue = [inProtocol readI64];
          [self setA: fieldValue];
        } else {
          [TProtocolUtil skipType: fieldType onProtocol: inProtocol];
        }
        break;
      default:
        [TProtocolUtil skipType: fieldType onProtocol: inProtocol];
        break;
    }
    [inProtocol readFieldEnd];
  }
  [inProtocol readStructEnd];
}

- (void) write: (id <TProtocol>) outProtocol {
  [outProtocol writeStructBeginWithName: @"Foo"];
  if (__thrift_a_set) {
    [outProtocol writeFieldBeginWithName: @"a" type: TType_I64 fieldID: 1];
    [outProtocol writeI64: __thrift_a];
    [outProtocol writeFieldEnd];
  }
  [outProtocol writeFieldStop];
  [outProtocol writeStructEnd];
}

- (void) validate {
  // check for required fields
}

- (NSString *) description {
  return [[self toDict] description];
}

- (NSDictionary *) toDict {
  NSMutableDictionary *ret = [NSMutableDictionary dictionary];
  ret[@"__thrift_struct_name"] = @"Foo";
  ret[@"a"] = @(__thrift_a);
  return [ret copy];
}

- (BOOL) makeImmutable {
  const BOOL wasImmutable = [self isImmutable];
  if (!wasImmutable) {
    [super makeImmutable];
  }
  return YES;
}

- (id) mutableCopyWithZone:(NSZone *)zone {
  Foo *newCopy = [[[self class] alloc] init];;
  newCopy->__thrift_a = self->__thrift_a;
  newCopy->__thrift_a_set = self->__thrift_a_set;
  return newCopy;
}

@end

