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

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

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

- (BOOL)hasProductName
{
    return _productName != nil;
}
@synthesize productName = _productName;
- (BOOL)hasProductType
{
    return _productType != nil;
}
@synthesize productType = _productType;
- (BOOL)hasProductVersion
{
    return _productVersion != nil;
}
@synthesize productVersion = _productVersion;
- (BOOL)hasProductBuild
{
    return _productBuild != nil;
}
@synthesize productBuild = _productBuild;
@synthesize isAppleInternal = _isAppleInternal;
- (void)setIsAppleInternal:(BOOL)v
{
    _has.isAppleInternal = YES;
    _isAppleInternal = v;
}
- (void)setHasIsAppleInternal:(BOOL)f
{
    _has.isAppleInternal = f;
}
- (BOOL)hasIsAppleInternal
{
    return _has.isAppleInternal;
}
- (BOOL)hasProcessName
{
    return _processName != nil;
}
@synthesize processName = _processName;
- (BOOL)hasProcessVersion
{
    return _processVersion != nil;
}
@synthesize processVersion = _processVersion;
- (BOOL)hasProcessUuid
{
    return _processUuid != nil;
}
@synthesize processUuid = _processUuid;
- (BOOL)hasUserDefaultTestName
{
    return _userDefaultTestName != nil;
}
@synthesize userDefaultTestName = _userDefaultTestName;
@synthesize internalTestConfigs = _internalTestConfigs;
- (void)clearInternalTestConfigs
{
    [_internalTestConfigs removeAllObjects];
}
- (void)addInternalTestConfig:(SECC2MPInternalTestConfig *)i
{
    if (!_internalTestConfigs)
    {
        _internalTestConfigs = [[NSMutableArray alloc] init];
    }
    [_internalTestConfigs addObject:i];
}
- (NSUInteger)internalTestConfigsCount
{
    return [_internalTestConfigs count];
}
- (SECC2MPInternalTestConfig *)internalTestConfigAtIndex:(NSUInteger)idx
{
    return [_internalTestConfigs objectAtIndex:idx];
}
+ (Class)internalTestConfigType
{
    return [SECC2MPInternalTestConfig class];
}

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

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    if (self->_productName)
    {
        [dict setObject:self->_productName forKey:@"product_name"];
    }
    if (self->_productType)
    {
        [dict setObject:self->_productType forKey:@"product_type"];
    }
    if (self->_productVersion)
    {
        [dict setObject:self->_productVersion forKey:@"product_version"];
    }
    if (self->_productBuild)
    {
        [dict setObject:self->_productBuild forKey:@"product_build"];
    }
    if (self->_has.isAppleInternal)
    {
        [dict setObject:[NSNumber numberWithBool:self->_isAppleInternal] forKey:@"is_apple_internal"];
    }
    if (self->_processName)
    {
        [dict setObject:self->_processName forKey:@"process_name"];
    }
    if (self->_processVersion)
    {
        [dict setObject:self->_processVersion forKey:@"process_version"];
    }
    if (self->_processUuid)
    {
        [dict setObject:self->_processUuid forKey:@"process_uuid"];
    }
    if (self->_userDefaultTestName)
    {
        [dict setObject:self->_userDefaultTestName forKey:@"user_default_test_name"];
    }
    if ([self->_internalTestConfigs count])
    {
        NSMutableArray *internalTestConfigsDictReprs = [[NSMutableArray alloc] initWithCapacity:[self->_internalTestConfigs count]];
        for (SECC2MPInternalTestConfig *i_internalTestConfig in self->_internalTestConfigs)
        {
            [internalTestConfigsDictReprs addObject:[i_internalTestConfig dictionaryRepresentation]];
        }
        [dict setObject:internalTestConfigsDictReprs forKey:@"internal_test_config"];
    }
    return dict;
}

BOOL SECC2MPDeviceInfoReadFrom(__unsafe_unretained SECC2MPDeviceInfo *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 101 /* productName */:
            {
                NSString *new_productName = PBReaderReadString(reader);
                self->_productName = new_productName;
            }
            break;
            case 102 /* productType */:
            {
                NSString *new_productType = PBReaderReadString(reader);
                self->_productType = new_productType;
            }
            break;
            case 103 /* productVersion */:
            {
                NSString *new_productVersion = PBReaderReadString(reader);
                self->_productVersion = new_productVersion;
            }
            break;
            case 104 /* productBuild */:
            {
                NSString *new_productBuild = PBReaderReadString(reader);
                self->_productBuild = new_productBuild;
            }
            break;
            case 105 /* isAppleInternal */:
            {
                self->_has.isAppleInternal = YES;
                self->_isAppleInternal = PBReaderReadBOOL(reader);
            }
            break;
            case 201 /* processName */:
            {
                NSString *new_processName = PBReaderReadString(reader);
                self->_processName = new_processName;
            }
            break;
            case 202 /* processVersion */:
            {
                NSString *new_processVersion = PBReaderReadString(reader);
                self->_processVersion = new_processVersion;
            }
            break;
            case 203 /* processUuid */:
            {
                NSString *new_processUuid = PBReaderReadString(reader);
                self->_processUuid = new_processUuid;
            }
            break;
            case 301 /* userDefaultTestName */:
            {
                NSString *new_userDefaultTestName = PBReaderReadString(reader);
                self->_userDefaultTestName = new_userDefaultTestName;
            }
            break;
            case 302 /* internalTestConfigs */:
            {
                SECC2MPInternalTestConfig *new_internalTestConfig = [[SECC2MPInternalTestConfig alloc] init];
                [self addInternalTestConfig:new_internalTestConfig];
                PBDataReaderMark mark_internalTestConfig;
                BOOL markError = !PBReaderPlaceMark(reader, &mark_internalTestConfig);
                if (markError)
                {
                    return NO;
                }
                BOOL inError = !SECC2MPInternalTestConfigReadFrom(new_internalTestConfig, reader);
                if (inError)
                {
                    return NO;
                }
                PBReaderRecallMark(reader, &mark_internalTestConfig);
            }
            break;
            default:
                if (!PBReaderSkipValueWithTag(reader, tag, aType))
                    return NO;
                break;
        }
    }
    return !PBReaderHasError(reader);
}

- (BOOL)readFrom:(PBDataReader *)reader
{
    return SECC2MPDeviceInfoReadFrom(self, reader);
}
- (void)writeTo:(PBDataWriter *)writer
{
    /* productName */
    {
        if (self->_productName)
        {
            PBDataWriterWriteStringField(writer, self->_productName, 101);
        }
    }
    /* productType */
    {
        if (self->_productType)
        {
            PBDataWriterWriteStringField(writer, self->_productType, 102);
        }
    }
    /* productVersion */
    {
        if (self->_productVersion)
        {
            PBDataWriterWriteStringField(writer, self->_productVersion, 103);
        }
    }
    /* productBuild */
    {
        if (self->_productBuild)
        {
            PBDataWriterWriteStringField(writer, self->_productBuild, 104);
        }
    }
    /* isAppleInternal */
    {
        if (self->_has.isAppleInternal)
        {
            PBDataWriterWriteBOOLField(writer, self->_isAppleInternal, 105);
        }
    }
    /* processName */
    {
        if (self->_processName)
        {
            PBDataWriterWriteStringField(writer, self->_processName, 201);
        }
    }
    /* processVersion */
    {
        if (self->_processVersion)
        {
            PBDataWriterWriteStringField(writer, self->_processVersion, 202);
        }
    }
    /* processUuid */
    {
        if (self->_processUuid)
        {
            PBDataWriterWriteStringField(writer, self->_processUuid, 203);
        }
    }
    /* userDefaultTestName */
    {
        if (self->_userDefaultTestName)
        {
            PBDataWriterWriteStringField(writer, self->_userDefaultTestName, 301);
        }
    }
    /* internalTestConfigs */
    {
        for (SECC2MPInternalTestConfig *i_internalTestConfig in self->_internalTestConfigs)
        {
            PBDataWriterWriteSubmessage(writer, i_internalTestConfig, 302);
        }
    }
}

- (void)copyTo:(SECC2MPDeviceInfo *)other
{
    if (_productName)
    {
        other.productName = _productName;
    }
    if (_productType)
    {
        other.productType = _productType;
    }
    if (_productVersion)
    {
        other.productVersion = _productVersion;
    }
    if (_productBuild)
    {
        other.productBuild = _productBuild;
    }
    if (self->_has.isAppleInternal)
    {
        other->_isAppleInternal = _isAppleInternal;
        other->_has.isAppleInternal = YES;
    }
    if (_processName)
    {
        other.processName = _processName;
    }
    if (_processVersion)
    {
        other.processVersion = _processVersion;
    }
    if (_processUuid)
    {
        other.processUuid = _processUuid;
    }
    if (_userDefaultTestName)
    {
        other.userDefaultTestName = _userDefaultTestName;
    }
    if ([self internalTestConfigsCount])
    {
        [other clearInternalTestConfigs];
        NSUInteger internalTestConfigsCnt = [self internalTestConfigsCount];
        for (NSUInteger i = 0; i < internalTestConfigsCnt; i++)
        {
            [other addInternalTestConfig:[self internalTestConfigAtIndex:i]];
        }
    }
}

- (id)copyWithZone:(NSZone *)zone
{
    SECC2MPDeviceInfo *copy = [[[self class] allocWithZone:zone] init];
    copy->_productName = [_productName copyWithZone:zone];
    copy->_productType = [_productType copyWithZone:zone];
    copy->_productVersion = [_productVersion copyWithZone:zone];
    copy->_productBuild = [_productBuild copyWithZone:zone];
    if (self->_has.isAppleInternal)
    {
        copy->_isAppleInternal = _isAppleInternal;
        copy->_has.isAppleInternal = YES;
    }
    copy->_processName = [_processName copyWithZone:zone];
    copy->_processVersion = [_processVersion copyWithZone:zone];
    copy->_processUuid = [_processUuid copyWithZone:zone];
    copy->_userDefaultTestName = [_userDefaultTestName copyWithZone:zone];
    for (SECC2MPInternalTestConfig *v in _internalTestConfigs)
    {
        SECC2MPInternalTestConfig *vCopy = [v copyWithZone:zone];
        [copy addInternalTestConfig:vCopy];
    }
    return copy;
}

- (BOOL)isEqual:(id)object
{
    SECC2MPDeviceInfo *other = (SECC2MPDeviceInfo *)object;
    return [other isMemberOfClass:[self class]]
    &&
    ((!self->_productName && !other->_productName) || [self->_productName isEqual:other->_productName])
    &&
    ((!self->_productType && !other->_productType) || [self->_productType isEqual:other->_productType])
    &&
    ((!self->_productVersion && !other->_productVersion) || [self->_productVersion isEqual:other->_productVersion])
    &&
    ((!self->_productBuild && !other->_productBuild) || [self->_productBuild isEqual:other->_productBuild])
    &&
    ((self->_has.isAppleInternal && other->_has.isAppleInternal && ((self->_isAppleInternal && other->_isAppleInternal) || (!self->_isAppleInternal && !other->_isAppleInternal))) || (!self->_has.isAppleInternal && !other->_has.isAppleInternal))
    &&
    ((!self->_processName && !other->_processName) || [self->_processName isEqual:other->_processName])
    &&
    ((!self->_processVersion && !other->_processVersion) || [self->_processVersion isEqual:other->_processVersion])
    &&
    ((!self->_processUuid && !other->_processUuid) || [self->_processUuid isEqual:other->_processUuid])
    &&
    ((!self->_userDefaultTestName && !other->_userDefaultTestName) || [self->_userDefaultTestName isEqual:other->_userDefaultTestName])
    &&
    ((!self->_internalTestConfigs && !other->_internalTestConfigs) || [self->_internalTestConfigs isEqual:other->_internalTestConfigs])
    ;
}

- (NSUInteger)hash
{
    return 0
    ^
    [self->_productName hash]
    ^
    [self->_productType hash]
    ^
    [self->_productVersion hash]
    ^
    [self->_productBuild hash]
    ^
    (self->_has.isAppleInternal ? PBHashInt((NSUInteger)self->_isAppleInternal) : 0)
    ^
    [self->_processName hash]
    ^
    [self->_processVersion hash]
    ^
    [self->_processUuid hash]
    ^
    [self->_userDefaultTestName hash]
    ^
    [self->_internalTestConfigs hash]
    ;
}

- (void)mergeFrom:(SECC2MPDeviceInfo *)other
{
    if (other->_productName)
    {
        [self setProductName:other->_productName];
    }
    if (other->_productType)
    {
        [self setProductType:other->_productType];
    }
    if (other->_productVersion)
    {
        [self setProductVersion:other->_productVersion];
    }
    if (other->_productBuild)
    {
        [self setProductBuild:other->_productBuild];
    }
    if (other->_has.isAppleInternal)
    {
        self->_isAppleInternal = other->_isAppleInternal;
        self->_has.isAppleInternal = YES;
    }
    if (other->_processName)
    {
        [self setProcessName:other->_processName];
    }
    if (other->_processVersion)
    {
        [self setProcessVersion:other->_processVersion];
    }
    if (other->_processUuid)
    {
        [self setProcessUuid:other->_processUuid];
    }
    if (other->_userDefaultTestName)
    {
        [self setUserDefaultTestName:other->_userDefaultTestName];
    }
    for (SECC2MPInternalTestConfig *iter_internalTestConfigs in other->_internalTestConfigs)
    {
        [self addInternalTestConfig:iter_internalTestConfigs];
    }
}

@end

