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

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

@synthesize pendingBackupPeers = _pendingBackupPeers;
- (void)clearPendingBackupPeers
{
    [_pendingBackupPeers removeAllObjects];
}
- (void)addPendingBackupPeers:(NSString *)i
{
    if (!_pendingBackupPeers)
    {
        _pendingBackupPeers = [[NSMutableArray alloc] init];
    }
    [_pendingBackupPeers addObject:i];
}
- (NSUInteger)pendingBackupPeersCount
{
    return [_pendingBackupPeers count];
}
- (NSString *)pendingBackupPeersAtIndex:(NSUInteger)idx
{
    return [_pendingBackupPeers objectAtIndex:idx];
}
+ (Class)pendingBackupPeersType
{
    return [NSString class];
}
@synthesize ringUpdateFlag = _ringUpdateFlag;
- (void)setRingUpdateFlag:(BOOL)v
{
    _has.ringUpdateFlag = YES;
    _ringUpdateFlag = v;
}
- (void)setHasRingUpdateFlag:(BOOL)f
{
    _has.ringUpdateFlag = f;
}
- (BOOL)hasRingUpdateFlag
{
    return _has.ringUpdateFlag != 0;
}

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

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    if (self->_pendingBackupPeers)
    {
        [dict setObject:self->_pendingBackupPeers forKey:@"pendingBackupPeers"];
    }
    if (self->_has.ringUpdateFlag)
    {
        [dict setObject:[NSNumber numberWithBool:self->_ringUpdateFlag] forKey:@"ringUpdateFlag"];
    }
    return dict;
}

BOOL SOSAccountConfigurationReadFrom(__unsafe_unretained SOSAccountConfiguration *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 /* pendingBackupPeers */:
            {
                NSString *new_pendingBackupPeers = PBReaderReadString(reader);
                if (new_pendingBackupPeers)
                {
                    [self addPendingBackupPeers:new_pendingBackupPeers];
                }
            }
            break;
            case 2 /* ringUpdateFlag */:
            {
                self->_has.ringUpdateFlag = YES;
                self->_ringUpdateFlag = PBReaderReadBOOL(reader);
            }
            break;
            default:
                if (!PBReaderSkipValueWithTag(reader, tag, aType))
                    return NO;
                break;
        }
    }
    return !PBReaderHasError(reader);
}

- (BOOL)readFrom:(PBDataReader *)reader
{
    return SOSAccountConfigurationReadFrom(self, reader);
}
- (void)writeTo:(PBDataWriter *)writer
{
    /* pendingBackupPeers */
    {
        for (NSString *s_pendingBackupPeers in self->_pendingBackupPeers)
        {
            PBDataWriterWriteStringField(writer, s_pendingBackupPeers, 1);
        }
    }
    /* ringUpdateFlag */
    {
        if (self->_has.ringUpdateFlag)
        {
            PBDataWriterWriteBOOLField(writer, self->_ringUpdateFlag, 2);
        }
    }
}

- (void)copyTo:(SOSAccountConfiguration *)other
{
    if ([self pendingBackupPeersCount])
    {
        [other clearPendingBackupPeers];
        NSUInteger pendingBackupPeersCnt = [self pendingBackupPeersCount];
        for (NSUInteger i = 0; i < pendingBackupPeersCnt; i++)
        {
            [other addPendingBackupPeers:[self pendingBackupPeersAtIndex:i]];
        }
    }
    if (self->_has.ringUpdateFlag)
    {
        other->_ringUpdateFlag = _ringUpdateFlag;
        other->_has.ringUpdateFlag = YES;
    }
}

- (id)copyWithZone:(NSZone *)zone
{
    SOSAccountConfiguration *copy = [[[self class] allocWithZone:zone] init];
    for (NSString *v in _pendingBackupPeers)
    {
        NSString *vCopy = [v copyWithZone:zone];
        [copy addPendingBackupPeers:vCopy];
    }
    if (self->_has.ringUpdateFlag)
    {
        copy->_ringUpdateFlag = _ringUpdateFlag;
        copy->_has.ringUpdateFlag = YES;
    }
    return copy;
}

- (BOOL)isEqual:(id)object
{
    SOSAccountConfiguration *other = (SOSAccountConfiguration *)object;
    return [other isMemberOfClass:[self class]]
    &&
    ((!self->_pendingBackupPeers && !other->_pendingBackupPeers) || [self->_pendingBackupPeers isEqual:other->_pendingBackupPeers])
    &&
    ((self->_has.ringUpdateFlag && other->_has.ringUpdateFlag && ((self->_ringUpdateFlag && other->_ringUpdateFlag) || (!self->_ringUpdateFlag && !other->_ringUpdateFlag))) || (!self->_has.ringUpdateFlag && !other->_has.ringUpdateFlag))
    ;
}

- (NSUInteger)hash
{
    return 0
    ^
    [self->_pendingBackupPeers hash]
    ^
    (self->_has.ringUpdateFlag ? PBHashInt((NSUInteger)self->_ringUpdateFlag) : 0)
    ;
}

- (void)mergeFrom:(SOSAccountConfiguration *)other
{
    for (NSString *iter_pendingBackupPeers in other->_pendingBackupPeers)
    {
        [self addPendingBackupPeers:iter_pendingBackupPeers];
    }
    if (other->_has.ringUpdateFlag)
    {
        self->_ringUpdateFlag = other->_ringUpdateFlag;
        self->_has.ringUpdateFlag = YES;
    }
}

@end

