/// Generated by the Protocol Buffers 3.6.0 compiler.  DO NOT EDIT!
/// Protobuf-swift version: 4.0.0
/// Source file "unittest_threading.proto"
/// Syntax "Proto3"

import Foundation
import ProtocolBuffers


public struct UnittestThreadingRoot {
    public static let `default` = UnittestThreadingRoot()
    public var extensionRegistry:ExtensionRegistry

    init() {
        extensionRegistry = ExtensionRegistry()
        registerAllExtensions(registry: extensionRegistry)
    }
    public func registerAllExtensions(registry: ExtensionRegistry) {
    }
}

final public class ThreadingMessages : GeneratedMessage {
    public typealias BuilderType = ThreadingMessages.Builder

    public static func == (lhs: ThreadingMessages, rhs: ThreadingMessages) -> Bool {
        if lhs === rhs {
            return true
        }
        var fieldCheck:Bool = (lhs.hashValue == rhs.hashValue)
        fieldCheck = fieldCheck && (lhs.hasTestString == rhs.hasTestString) && (!lhs.hasTestString || lhs.testString == rhs.testString)
        fieldCheck = (fieldCheck && (lhs.unknownFields == rhs.unknownFields))
        return fieldCheck
    }

    public fileprivate(set) var testString:String! = nil
    public fileprivate(set) var hasTestString:Bool = false

    required public init() {
        super.init()
    }
    override public func isInitialized() throws {
    }
    override public func writeTo(codedOutputStream: CodedOutputStream) throws {
        if hasTestString {
            try codedOutputStream.writeString(fieldNumber: 1, value:testString)
        }
        try unknownFields.writeTo(codedOutputStream: codedOutputStream)
    }
    override public func serializedSize() -> Int32 {
        var serialize_size:Int32 = memoizedSerializedSize
        if serialize_size != -1 {
         return serialize_size
        }

        serialize_size = 0
        if hasTestString {
            serialize_size += testString.computeStringSize(fieldNumber: 1)
        }
        serialize_size += unknownFields.serializedSize()
        memoizedSerializedSize = serialize_size
        return serialize_size
    }
    public class func getBuilder() -> ThreadingMessages.Builder {
        return ThreadingMessages.classBuilder() as! ThreadingMessages.Builder
    }
    public func getBuilder() -> ThreadingMessages.Builder {
        return classBuilder() as! ThreadingMessages.Builder
    }
    override public class func classBuilder() -> ProtocolBuffersMessageBuilder {
        return ThreadingMessages.Builder()
    }
    override public func classBuilder() -> ProtocolBuffersMessageBuilder {
        return ThreadingMessages.Builder()
    }
    public func toBuilder() throws -> ThreadingMessages.Builder {
        return try ThreadingMessages.builderWithPrototype(prototype:self)
    }
    public class func builderWithPrototype(prototype:ThreadingMessages) throws -> ThreadingMessages.Builder {
        return try ThreadingMessages.Builder().mergeFrom(other:prototype)
    }
    override public func encode() throws -> Dictionary<String,Any> {
        try isInitialized()
        var jsonMap:Dictionary<String,Any> = Dictionary<String,Any>()
        if hasTestString {
            jsonMap["testString"] = testString
        }
        return jsonMap
    }
    override class public func decode(jsonMap:Dictionary<String,Any>) throws -> ThreadingMessages {
        return try ThreadingMessages.Builder.decodeToBuilder(jsonMap:jsonMap).build()
    }
    override class public func fromJSON(data:Data, options: JSONSerialization.ReadingOptions = []) throws -> ThreadingMessages {
        return try ThreadingMessages.Builder.fromJSONToBuilder(data:data, options:options).build()
    }
    override public func getDescription(indent:String) throws -> String {
        var output = ""
        if hasTestString {
            output += "\(indent) testString: \(String(describing: testString)) \n"
        }
        output += unknownFields.getDescription(indent: indent)
        return output
    }
    override public var hashValue:Int {
        get {
            var hashCode:Int = 7
            if hasTestString {
                hashCode = (hashCode &* 31) &+ testString.hashValue
            }
            hashCode = (hashCode &* 31) &+  unknownFields.hashValue
            return hashCode
        }
    }


    //Meta information declaration start

    override public class func className() -> String {
        return "ThreadingMessages"
    }
    override public func className() -> String {
        return "ThreadingMessages"
    }
    //Meta information declaration end

    final public class Builder : GeneratedMessageBuilder {
        fileprivate var builderResult:ThreadingMessages = ThreadingMessages()
        public func getMessage() -> ThreadingMessages {
            return builderResult
        }

        required override public init () {
            super.init()
        }
        public var testString:String {
            get {
                return builderResult.testString
            }
            set (value) {
                builderResult.hasTestString = true
                builderResult.testString = value
            }
        }
        public var hasTestString:Bool {
            get {
                return builderResult.hasTestString
            }
        }
        @discardableResult
        public func setTestString(_ value:String) -> ThreadingMessages.Builder {
            self.testString = value
            return self
        }
        @discardableResult
        public func clearTestString() -> ThreadingMessages.Builder{
            builderResult.hasTestString = false
            builderResult.testString = nil
            return self
        }
        override public var internalGetResult:GeneratedMessage {
            get {
                return builderResult
            }
        }
        @discardableResult
        override public func clear() -> ThreadingMessages.Builder {
            builderResult = ThreadingMessages()
            return self
        }
        override public func clone() throws -> ThreadingMessages.Builder {
            return try ThreadingMessages.builderWithPrototype(prototype:builderResult)
        }
        override public func build() throws -> ThreadingMessages {
            try checkInitialized()
            return buildPartial()
        }
        public func buildPartial() -> ThreadingMessages {
            let returnMe:ThreadingMessages = builderResult
            return returnMe
        }
        @discardableResult
        public func mergeFrom(other:ThreadingMessages) throws -> ThreadingMessages.Builder {
            if other == ThreadingMessages() {
                return self
            }
            if other.hasTestString {
                testString = other.testString
            }
            try merge(unknownField: other.unknownFields)
            return self
        }
        @discardableResult
        override public func mergeFrom(codedInputStream: CodedInputStream) throws -> ThreadingMessages.Builder {
            return try mergeFrom(codedInputStream: codedInputStream, extensionRegistry:ExtensionRegistry())
        }
        @discardableResult
        override public func mergeFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> ThreadingMessages.Builder {
            let unknownFieldsBuilder:UnknownFieldSet.Builder = try UnknownFieldSet.builderWithUnknownFields(copyFrom:self.unknownFields)
            while (true) {
                let protobufTag = try codedInputStream.readTag()
                switch protobufTag {
                case 0: 
                    self.unknownFields = try unknownFieldsBuilder.build()
                    return self

                case 10:
                    testString = try codedInputStream.readString()

                default:
                    if (!(try parse(codedInputStream:codedInputStream, unknownFields:unknownFieldsBuilder, extensionRegistry:extensionRegistry, tag:protobufTag))) {
                        unknownFields = try unknownFieldsBuilder.build()
                        return self
                    }
                }
            }
        }
        class override public func decodeToBuilder(jsonMap:Dictionary<String,Any>) throws -> ThreadingMessages.Builder {
            let resultDecodedBuilder = ThreadingMessages.Builder()
            if let jsonValueTestString = jsonMap["testString"] as? String {
                resultDecodedBuilder.testString = jsonValueTestString
            }
            return resultDecodedBuilder
        }
        override class public func fromJSONToBuilder(data:Data, options: JSONSerialization.ReadingOptions = []) throws -> ThreadingMessages.Builder {
            let jsonData = try JSONSerialization.jsonObject(with:data, options: options)
            guard let jsDataCast = jsonData as? Dictionary<String,Any> else {
              throw ProtocolBuffersError.invalidProtocolBuffer("Invalid JSON data")
            }
            return try ThreadingMessages.Builder.decodeToBuilder(jsonMap:jsDataCast)
        }
    }

}

extension ThreadingMessages: GeneratedMessageProtocol {
    public class func parseArrayDelimitedFrom(inputStream: InputStream) throws -> Array<ThreadingMessages> {
        var mergedArray = Array<ThreadingMessages>()
        while let value = try parseDelimitedFrom(inputStream: inputStream) {
          mergedArray.append(value)
        }
        return mergedArray
    }
    public class func parseDelimitedFrom(inputStream: InputStream) throws -> ThreadingMessages? {
        return try ThreadingMessages.Builder().mergeDelimitedFrom(inputStream: inputStream)?.build()
    }
    public class func parseFrom(data: Data) throws -> ThreadingMessages {
        return try ThreadingMessages.Builder().mergeFrom(data: data, extensionRegistry:UnittestThreadingRoot.default.extensionRegistry).build()
    }
    public class func parseFrom(data: Data, extensionRegistry:ExtensionRegistry) throws -> ThreadingMessages {
        return try ThreadingMessages.Builder().mergeFrom(data: data, extensionRegistry:extensionRegistry).build()
    }
    public class func parseFrom(inputStream: InputStream) throws -> ThreadingMessages {
        return try ThreadingMessages.Builder().mergeFrom(inputStream: inputStream).build()
    }
    public class func parseFrom(inputStream: InputStream, extensionRegistry:ExtensionRegistry) throws -> ThreadingMessages {
        return try ThreadingMessages.Builder().mergeFrom(inputStream: inputStream, extensionRegistry:extensionRegistry).build()
    }
    public class func parseFrom(codedInputStream: CodedInputStream) throws -> ThreadingMessages {
        return try ThreadingMessages.Builder().mergeFrom(codedInputStream: codedInputStream).build()
    }
    public class func parseFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> ThreadingMessages {
        return try ThreadingMessages.Builder().mergeFrom(codedInputStream: codedInputStream, extensionRegistry:extensionRegistry).build()
    }
    public subscript(key: String) -> Any? {
        switch key {
        case "testString": return self.testString
        default: return nil
        }
    }
}
extension ThreadingMessages.Builder: GeneratedMessageBuilderProtocol {
    public typealias GeneratedMessageType = ThreadingMessages
    public subscript(key: String) -> Any? {
        get { 
            switch key {
            case "testString": return self.testString
            default: return nil
            }
        }
        set (newSubscriptValue) { 
            switch key {
            case "testString":
                guard let newSubscriptValue = newSubscriptValue as? String else {
                    return
                }
                self.testString = newSubscriptValue
            default: return
            }
        }
    }
}

// @@protoc_insertion_point(global_scope)
