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

#import "OTApplicantToSponsorRound2M1.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 OTApplicantToSponsorRound2M1

- (BOOL)hasPeerID
{
    return _peerID != nil;
}
@synthesize peerID = _peerID;
- (BOOL)hasPermanentInfo
{
    return _permanentInfo != nil;
}
@synthesize permanentInfo = _permanentInfo;
- (BOOL)hasPermanentInfoSig
{
    return _permanentInfoSig != nil;
}
@synthesize permanentInfoSig = _permanentInfoSig;
- (BOOL)hasStableInfo
{
    return _stableInfo != nil;
}
@synthesize stableInfo = _stableInfo;
- (BOOL)hasStableInfoSig
{
    return _stableInfoSig != nil;
}
@synthesize stableInfoSig = _stableInfoSig;

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

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    if (self->_peerID)
    {
        [dict setObject:self->_peerID forKey:@"peerID"];
    }
    if (self->_permanentInfo)
    {
        [dict setObject:self->_permanentInfo forKey:@"permanentInfo"];
    }
    if (self->_permanentInfoSig)
    {
        [dict setObject:self->_permanentInfoSig forKey:@"permanentInfoSig"];
    }
    if (self->_stableInfo)
    {
        [dict setObject:self->_stableInfo forKey:@"stableInfo"];
    }
    if (self->_stableInfoSig)
    {
        [dict setObject:self->_stableInfoSig forKey:@"StableInfoSig"];
    }
    return dict;
}

BOOL OTApplicantToSponsorRound2M1ReadFrom(__unsafe_unretained OTApplicantToSponsorRound2M1 *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 /* peerID */:
            {
                NSString *new_peerID = PBReaderReadString(reader);
                self->_peerID = new_peerID;
            }
            break;
            case 2 /* permanentInfo */:
            {
                NSData *new_permanentInfo = PBReaderReadData(reader);
                self->_permanentInfo = new_permanentInfo;
            }
            break;
            case 3 /* permanentInfoSig */:
            {
                NSData *new_permanentInfoSig = PBReaderReadData(reader);
                self->_permanentInfoSig = new_permanentInfoSig;
            }
            break;
            case 4 /* stableInfo */:
            {
                NSData *new_stableInfo = PBReaderReadData(reader);
                self->_stableInfo = new_stableInfo;
            }
            break;
            case 5 /* stableInfoSig */:
            {
                NSData *new_stableInfoSig = PBReaderReadData(reader);
                self->_stableInfoSig = new_stableInfoSig;
            }
            break;
            default:
                if (!PBReaderSkipValueWithTag(reader, tag, aType))
                    return NO;
                break;
        }
    }
    return !PBReaderHasError(reader);
}

- (BOOL)readFrom:(PBDataReader *)reader
{
    return OTApplicantToSponsorRound2M1ReadFrom(self, reader);
}
- (void)writeTo:(PBDataWriter *)writer
{
    /* peerID */
    {
        if (self->_peerID)
        {
            PBDataWriterWriteStringField(writer, self->_peerID, 1);
        }
    }
    /* permanentInfo */
    {
        if (self->_permanentInfo)
        {
            PBDataWriterWriteDataField(writer, self->_permanentInfo, 2);
        }
    }
    /* permanentInfoSig */
    {
        if (self->_permanentInfoSig)
        {
            PBDataWriterWriteDataField(writer, self->_permanentInfoSig, 3);
        }
    }
    /* stableInfo */
    {
        if (self->_stableInfo)
        {
            PBDataWriterWriteDataField(writer, self->_stableInfo, 4);
        }
    }
    /* stableInfoSig */
    {
        if (self->_stableInfoSig)
        {
            PBDataWriterWriteDataField(writer, self->_stableInfoSig, 5);
        }
    }
}

- (void)copyTo:(OTApplicantToSponsorRound2M1 *)other
{
    if (_peerID)
    {
        other.peerID = _peerID;
    }
    if (_permanentInfo)
    {
        other.permanentInfo = _permanentInfo;
    }
    if (_permanentInfoSig)
    {
        other.permanentInfoSig = _permanentInfoSig;
    }
    if (_stableInfo)
    {
        other.stableInfo = _stableInfo;
    }
    if (_stableInfoSig)
    {
        other.stableInfoSig = _stableInfoSig;
    }
}

- (id)copyWithZone:(NSZone *)zone
{
    OTApplicantToSponsorRound2M1 *copy = [[[self class] allocWithZone:zone] init];
    copy->_peerID = [_peerID copyWithZone:zone];
    copy->_permanentInfo = [_permanentInfo copyWithZone:zone];
    copy->_permanentInfoSig = [_permanentInfoSig copyWithZone:zone];
    copy->_stableInfo = [_stableInfo copyWithZone:zone];
    copy->_stableInfoSig = [_stableInfoSig copyWithZone:zone];
    return copy;
}

- (BOOL)isEqual:(id)object
{
    OTApplicantToSponsorRound2M1 *other = (OTApplicantToSponsorRound2M1 *)object;
    return [other isMemberOfClass:[self class]]
    &&
    ((!self->_peerID && !other->_peerID) || [self->_peerID isEqual:other->_peerID])
    &&
    ((!self->_permanentInfo && !other->_permanentInfo) || [self->_permanentInfo isEqual:other->_permanentInfo])
    &&
    ((!self->_permanentInfoSig && !other->_permanentInfoSig) || [self->_permanentInfoSig isEqual:other->_permanentInfoSig])
    &&
    ((!self->_stableInfo && !other->_stableInfo) || [self->_stableInfo isEqual:other->_stableInfo])
    &&
    ((!self->_stableInfoSig && !other->_stableInfoSig) || [self->_stableInfoSig isEqual:other->_stableInfoSig])
    ;
}

- (NSUInteger)hash
{
    return 0
    ^
    [self->_peerID hash]
    ^
    [self->_permanentInfo hash]
    ^
    [self->_permanentInfoSig hash]
    ^
    [self->_stableInfo hash]
    ^
    [self->_stableInfoSig hash]
    ;
}

- (void)mergeFrom:(OTApplicantToSponsorRound2M1 *)other
{
    if (other->_peerID)
    {
        [self setPeerID:other->_peerID];
    }
    if (other->_permanentInfo)
    {
        [self setPermanentInfo:other->_permanentInfo];
    }
    if (other->_permanentInfoSig)
    {
        [self setPermanentInfoSig:other->_permanentInfoSig];
    }
    if (other->_stableInfo)
    {
        [self setStableInfo:other->_stableInfo];
    }
    if (other->_stableInfoSig)
    {
        [self setStableInfoSig:other->_stableInfoSig];
    }
}

@end

