// This file was automatically generated by protocompiler
// DO NOT EDIT!
// Compiled from OTPairingMessage.proto

#import "OTSOSMessage.h"
#import <ProtocolBuffer/PBConstants.h>
#import <ProtocolBuffer/PBHashUtil.h>
#import <ProtocolBuffer/PBDataReader.h>

#if !__has_feature(objc_arc)
# error This generated file depends on ARC but it is not enabled; turn on ARC, or use 'objc_use_arc' option to generate non-ARC code.
#endif

@implementation OTSOSMessage

- (BOOL)hasCredential
{
    return _credential != nil;
}
@synthesize credential = _credential;
- (BOOL)hasPeerInfo
{
    return _peerInfo != nil;
}
@synthesize peerInfo = _peerInfo;
- (BOOL)hasCircleBlob
{
    return _circleBlob != nil;
}
@synthesize circleBlob = _circleBlob;
- (BOOL)hasInitialSyncItems
{
    return _initialSyncItems != nil;
}
@synthesize initialSyncItems = _initialSyncItems;

- (NSString *)description
{
    return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    if (self->_credential)
    {
        [dict setObject:self->_credential forKey:@"credential"];
    }
    if (self->_peerInfo)
    {
        [dict setObject:self->_peerInfo forKey:@"peerInfo"];
    }
    if (self->_circleBlob)
    {
        [dict setObject:self->_circleBlob forKey:@"circleBlob"];
    }
    if (self->_initialSyncItems)
    {
        [dict setObject:self->_initialSyncItems forKey:@"initialSyncItems"];
    }
    return dict;
}

BOOL OTSOSMessageReadFrom(__unsafe_unretained OTSOSMessage *self, __unsafe_unretained PBDataReader *reader) {
    while (PBReaderHasMoreData(reader)) {
        uint32_t tag = 0;
        uint8_t aType = 0;

        PBReaderReadTag32AndType(reader, &tag, &aType);

        if (PBReaderHasError(reader))
            break;

        if (aType == TYPE_END_GROUP) {
            break;
        }

        switch (tag) {

            case 1 /* credential */:
            {
                NSData *new_credential = PBReaderReadData(reader);
                self->_credential = new_credential;
            }
            break;
            case 2 /* peerInfo */:
            {
                NSData *new_peerInfo = PBReaderReadData(reader);
                self->_peerInfo = new_peerInfo;
            }
            break;
            case 3 /* circleBlob */:
            {
                NSData *new_circleBlob = PBReaderReadData(reader);
                self->_circleBlob = new_circleBlob;
            }
            break;
            case 4 /* initialSyncItems */:
            {
                NSData *new_initialSyncItems = PBReaderReadData(reader);
                self->_initialSyncItems = new_initialSyncItems;
            }
            break;
            default:
                if (!PBReaderSkipValueWithTag(reader, tag, aType))
                    return NO;
                break;
        }
    }
    return !PBReaderHasError(reader);
}

- (BOOL)readFrom:(PBDataReader *)reader
{
    return OTSOSMessageReadFrom(self, reader);
}
- (void)writeTo:(PBDataWriter *)writer
{
    /* credential */
    {
        if (self->_credential)
        {
            PBDataWriterWriteDataField(writer, self->_credential, 1);
        }
    }
    /* peerInfo */
    {
        if (self->_peerInfo)
        {
            PBDataWriterWriteDataField(writer, self->_peerInfo, 2);
        }
    }
    /* circleBlob */
    {
        if (self->_circleBlob)
        {
            PBDataWriterWriteDataField(writer, self->_circleBlob, 3);
        }
    }
    /* initialSyncItems */
    {
        if (self->_initialSyncItems)
        {
            PBDataWriterWriteDataField(writer, self->_initialSyncItems, 4);
        }
    }
}

- (void)copyTo:(OTSOSMessage *)other
{
    if (_credential)
    {
        other.credential = _credential;
    }
    if (_peerInfo)
    {
        other.peerInfo = _peerInfo;
    }
    if (_circleBlob)
    {
        other.circleBlob = _circleBlob;
    }
    if (_initialSyncItems)
    {
        other.initialSyncItems = _initialSyncItems;
    }
}

- (id)copyWithZone:(NSZone *)zone
{
    OTSOSMessage *copy = [[[self class] allocWithZone:zone] init];
    copy->_credential = [_credential copyWithZone:zone];
    copy->_peerInfo = [_peerInfo copyWithZone:zone];
    copy->_circleBlob = [_circleBlob copyWithZone:zone];
    copy->_initialSyncItems = [_initialSyncItems copyWithZone:zone];
    return copy;
}

- (BOOL)isEqual:(id)object
{
    OTSOSMessage *other = (OTSOSMessage *)object;
    return [other isMemberOfClass:[self class]]
    &&
    ((!self->_credential && !other->_credential) || [self->_credential isEqual:other->_credential])
    &&
    ((!self->_peerInfo && !other->_peerInfo) || [self->_peerInfo isEqual:other->_peerInfo])
    &&
    ((!self->_circleBlob && !other->_circleBlob) || [self->_circleBlob isEqual:other->_circleBlob])
    &&
    ((!self->_initialSyncItems && !other->_initialSyncItems) || [self->_initialSyncItems isEqual:other->_initialSyncItems])
    ;
}

- (NSUInteger)hash
{
    return 0
    ^
    [self->_credential hash]
    ^
    [self->_peerInfo hash]
    ^
    [self->_circleBlob hash]
    ^
    [self->_initialSyncItems hash]
    ;
}

- (void)mergeFrom:(OTSOSMessage *)other
{
    if (other->_credential)
    {
        [self setCredential:other->_credential];
    }
    if (other->_peerInfo)
    {
        [self setPeerInfo:other->_peerInfo];
    }
    if (other->_circleBlob)
    {
        [self setCircleBlob:other->_circleBlob];
    }
    if (other->_initialSyncItems)
    {
        [self setInitialSyncItems:other->_initialSyncItems];
    }
}

@end

