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

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

- (BOOL)hasPeerID
{
    return _peerID != nil;
}
@synthesize peerID = _peerID;
@synthesize icloudAccountState = _icloudAccountState;
- (OTAccountMetadataClassC_AccountState)icloudAccountState
{
    return _has.icloudAccountState ? _icloudAccountState : OTAccountMetadataClassC_AccountState_UNKNOWN;
}
- (void)setIcloudAccountState:(OTAccountMetadataClassC_AccountState)v
{
    _has.icloudAccountState = YES;
    _icloudAccountState = v;
}
- (void)setHasIcloudAccountState:(BOOL)f
{
    _has.icloudAccountState = f;
}
- (BOOL)hasIcloudAccountState
{
    return _has.icloudAccountState;
}
- (NSString *)icloudAccountStateAsString:(OTAccountMetadataClassC_AccountState)value
{
    return OTAccountMetadataClassC_AccountStateAsString(value);
}
- (OTAccountMetadataClassC_AccountState)StringAsIcloudAccountState:(NSString *)str
{
    return StringAsOTAccountMetadataClassC_AccountState(str);
}
@synthesize epoch = _epoch;
- (void)setEpoch:(int64_t)v
{
    _has.epoch = YES;
    _epoch = v;
}
- (void)setHasEpoch:(BOOL)f
{
    _has.epoch = f;
}
- (BOOL)hasEpoch
{
    return _has.epoch;
}
- (BOOL)hasAltDSID
{
    return _altDSID != nil;
}
@synthesize altDSID = _altDSID;
@synthesize trustState = _trustState;
- (OTAccountMetadataClassC_TrustState)trustState
{
    return _has.trustState ? _trustState : OTAccountMetadataClassC_TrustState_UNKNOWN;
}
- (void)setTrustState:(OTAccountMetadataClassC_TrustState)v
{
    _has.trustState = YES;
    _trustState = v;
}
- (void)setHasTrustState:(BOOL)f
{
    _has.trustState = f;
}
- (BOOL)hasTrustState
{
    return _has.trustState;
}
- (NSString *)trustStateAsString:(OTAccountMetadataClassC_TrustState)value
{
    return OTAccountMetadataClassC_TrustStateAsString(value);
}
- (OTAccountMetadataClassC_TrustState)StringAsTrustState:(NSString *)str
{
    return StringAsOTAccountMetadataClassC_TrustState(str);
}
@synthesize lastHealthCheckup = _lastHealthCheckup;
- (void)setLastHealthCheckup:(uint64_t)v
{
    _has.lastHealthCheckup = YES;
    _lastHealthCheckup = v;
}
- (void)setHasLastHealthCheckup:(BOOL)f
{
    _has.lastHealthCheckup = f;
}
- (BOOL)hasLastHealthCheckup
{
    return _has.lastHealthCheckup;
}
@synthesize attemptedJoin = _attemptedJoin;
- (OTAccountMetadataClassC_AttemptedAJoinState)attemptedJoin
{
    return _has.attemptedJoin ? _attemptedJoin : OTAccountMetadataClassC_AttemptedAJoinState_UNKNOWN;
}
- (void)setAttemptedJoin:(OTAccountMetadataClassC_AttemptedAJoinState)v
{
    _has.attemptedJoin = YES;
    _attemptedJoin = v;
}
- (void)setHasAttemptedJoin:(BOOL)f
{
    _has.attemptedJoin = f;
}
- (BOOL)hasAttemptedJoin
{
    return _has.attemptedJoin;
}
- (NSString *)attemptedJoinAsString:(OTAccountMetadataClassC_AttemptedAJoinState)value
{
    return OTAccountMetadataClassC_AttemptedAJoinStateAsString(value);
}
- (OTAccountMetadataClassC_AttemptedAJoinState)StringAsAttemptedJoin:(NSString *)str
{
    return StringAsOTAccountMetadataClassC_AttemptedAJoinState(str);
}

- (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->_has.icloudAccountState)
    {
        [dict setObject:OTAccountMetadataClassC_AccountStateAsString(self->_icloudAccountState) forKey:@"icloudAccountState"];
    }
    if (self->_has.epoch)
    {
        [dict setObject:[NSNumber numberWithLongLong:self->_epoch] forKey:@"epoch"];
    }
    if (self->_altDSID)
    {
        [dict setObject:self->_altDSID forKey:@"altDSID"];
    }
    if (self->_has.trustState)
    {
        [dict setObject:OTAccountMetadataClassC_TrustStateAsString(self->_trustState) forKey:@"trustState"];
    }
    if (self->_has.lastHealthCheckup)
    {
        [dict setObject:[NSNumber numberWithUnsignedLongLong:self->_lastHealthCheckup] forKey:@"lastHealthCheckup"];
    }
    if (self->_has.attemptedJoin)
    {
        [dict setObject:OTAccountMetadataClassC_AttemptedAJoinStateAsString(self->_attemptedJoin) forKey:@"attemptedJoin"];
    }
    return dict;
}

BOOL OTAccountMetadataClassCReadFrom(__unsafe_unretained OTAccountMetadataClassC *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 /* icloudAccountState */:
            {
                self->_has.icloudAccountState = YES;
                self->_icloudAccountState = PBReaderReadInt32(reader);
            }
            break;
            case 3 /* epoch */:
            {
                self->_has.epoch = YES;
                self->_epoch = PBReaderReadInt64(reader);
            }
            break;
            case 4 /* altDSID */:
            {
                NSString *new_altDSID = PBReaderReadString(reader);
                self->_altDSID = new_altDSID;
            }
            break;
            case 5 /* trustState */:
            {
                self->_has.trustState = YES;
                self->_trustState = PBReaderReadInt32(reader);
            }
            break;
            case 6 /* lastHealthCheckup */:
            {
                self->_has.lastHealthCheckup = YES;
                self->_lastHealthCheckup = PBReaderReadUint64(reader);
            }
            break;
            case 7 /* attemptedJoin */:
            {
                self->_has.attemptedJoin = YES;
                self->_attemptedJoin = PBReaderReadInt32(reader);
            }
            break;
            default:
                if (!PBReaderSkipValueWithTag(reader, tag, aType))
                    return NO;
                break;
        }
    }
    return !PBReaderHasError(reader);
}

- (BOOL)readFrom:(PBDataReader *)reader
{
    return OTAccountMetadataClassCReadFrom(self, reader);
}
- (void)writeTo:(PBDataWriter *)writer
{
    /* peerID */
    {
        if (self->_peerID)
        {
            PBDataWriterWriteStringField(writer, self->_peerID, 1);
        }
    }
    /* icloudAccountState */
    {
        if (self->_has.icloudAccountState)
        {
            PBDataWriterWriteInt32Field(writer, self->_icloudAccountState, 2);
        }
    }
    /* epoch */
    {
        if (self->_has.epoch)
        {
            PBDataWriterWriteInt64Field(writer, self->_epoch, 3);
        }
    }
    /* altDSID */
    {
        if (self->_altDSID)
        {
            PBDataWriterWriteStringField(writer, self->_altDSID, 4);
        }
    }
    /* trustState */
    {
        if (self->_has.trustState)
        {
            PBDataWriterWriteInt32Field(writer, self->_trustState, 5);
        }
    }
    /* lastHealthCheckup */
    {
        if (self->_has.lastHealthCheckup)
        {
            PBDataWriterWriteUint64Field(writer, self->_lastHealthCheckup, 6);
        }
    }
    /* attemptedJoin */
    {
        if (self->_has.attemptedJoin)
        {
            PBDataWriterWriteInt32Field(writer, self->_attemptedJoin, 7);
        }
    }
}

- (void)copyTo:(OTAccountMetadataClassC *)other
{
    if (_peerID)
    {
        other.peerID = _peerID;
    }
    if (self->_has.icloudAccountState)
    {
        other->_icloudAccountState = _icloudAccountState;
        other->_has.icloudAccountState = YES;
    }
    if (self->_has.epoch)
    {
        other->_epoch = _epoch;
        other->_has.epoch = YES;
    }
    if (_altDSID)
    {
        other.altDSID = _altDSID;
    }
    if (self->_has.trustState)
    {
        other->_trustState = _trustState;
        other->_has.trustState = YES;
    }
    if (self->_has.lastHealthCheckup)
    {
        other->_lastHealthCheckup = _lastHealthCheckup;
        other->_has.lastHealthCheckup = YES;
    }
    if (self->_has.attemptedJoin)
    {
        other->_attemptedJoin = _attemptedJoin;
        other->_has.attemptedJoin = YES;
    }
}

- (id)copyWithZone:(NSZone *)zone
{
    OTAccountMetadataClassC *copy = [[[self class] allocWithZone:zone] init];
    copy->_peerID = [_peerID copyWithZone:zone];
    if (self->_has.icloudAccountState)
    {
        copy->_icloudAccountState = _icloudAccountState;
        copy->_has.icloudAccountState = YES;
    }
    if (self->_has.epoch)
    {
        copy->_epoch = _epoch;
        copy->_has.epoch = YES;
    }
    copy->_altDSID = [_altDSID copyWithZone:zone];
    if (self->_has.trustState)
    {
        copy->_trustState = _trustState;
        copy->_has.trustState = YES;
    }
    if (self->_has.lastHealthCheckup)
    {
        copy->_lastHealthCheckup = _lastHealthCheckup;
        copy->_has.lastHealthCheckup = YES;
    }
    if (self->_has.attemptedJoin)
    {
        copy->_attemptedJoin = _attemptedJoin;
        copy->_has.attemptedJoin = YES;
    }
    return copy;
}

- (BOOL)isEqual:(id)object
{
    OTAccountMetadataClassC *other = (OTAccountMetadataClassC *)object;
    return [other isMemberOfClass:[self class]]
    &&
    ((!self->_peerID && !other->_peerID) || [self->_peerID isEqual:other->_peerID])
    &&
    ((self->_has.icloudAccountState && other->_has.icloudAccountState && self->_icloudAccountState == other->_icloudAccountState) || (!self->_has.icloudAccountState && !other->_has.icloudAccountState))
    &&
    ((self->_has.epoch && other->_has.epoch && self->_epoch == other->_epoch) || (!self->_has.epoch && !other->_has.epoch))
    &&
    ((!self->_altDSID && !other->_altDSID) || [self->_altDSID isEqual:other->_altDSID])
    &&
    ((self->_has.trustState && other->_has.trustState && self->_trustState == other->_trustState) || (!self->_has.trustState && !other->_has.trustState))
    &&
    ((self->_has.lastHealthCheckup && other->_has.lastHealthCheckup && self->_lastHealthCheckup == other->_lastHealthCheckup) || (!self->_has.lastHealthCheckup && !other->_has.lastHealthCheckup))
    &&
    ((self->_has.attemptedJoin && other->_has.attemptedJoin && self->_attemptedJoin == other->_attemptedJoin) || (!self->_has.attemptedJoin && !other->_has.attemptedJoin))
    ;
}

- (NSUInteger)hash
{
    return 0
    ^
    [self->_peerID hash]
    ^
    (self->_has.icloudAccountState ? PBHashInt((NSUInteger)self->_icloudAccountState) : 0)
    ^
    (self->_has.epoch ? PBHashInt((NSUInteger)self->_epoch) : 0)
    ^
    [self->_altDSID hash]
    ^
    (self->_has.trustState ? PBHashInt((NSUInteger)self->_trustState) : 0)
    ^
    (self->_has.lastHealthCheckup ? PBHashInt((NSUInteger)self->_lastHealthCheckup) : 0)
    ^
    (self->_has.attemptedJoin ? PBHashInt((NSUInteger)self->_attemptedJoin) : 0)
    ;
}

- (void)mergeFrom:(OTAccountMetadataClassC *)other
{
    if (other->_peerID)
    {
        [self setPeerID:other->_peerID];
    }
    if (other->_has.icloudAccountState)
    {
        self->_icloudAccountState = other->_icloudAccountState;
        self->_has.icloudAccountState = YES;
    }
    if (other->_has.epoch)
    {
        self->_epoch = other->_epoch;
        self->_has.epoch = YES;
    }
    if (other->_altDSID)
    {
        [self setAltDSID:other->_altDSID];
    }
    if (other->_has.trustState)
    {
        self->_trustState = other->_trustState;
        self->_has.trustState = YES;
    }
    if (other->_has.lastHealthCheckup)
    {
        self->_lastHealthCheckup = other->_lastHealthCheckup;
        self->_has.lastHealthCheckup = YES;
    }
    if (other->_has.attemptedJoin)
    {
        self->_attemptedJoin = other->_attemptedJoin;
        self->_has.attemptedJoin = YES;
    }
}

@end

