     public var byteSwapped: BluetoothUUID {
         
         switch self {
-            
-        case let .bit16(value):
-            
-            return .bit16(value.byteSwapped)
-            
-        case let .bit32(value):
-            
-            return .bit32(value.byteSwapped)
-            
-        case let .bit128(value):
-            
-            return .bit128(value.byteSwapped)
+        case let .bit16(value): return .bit16(value.byteSwapped)
+        case let .bit32(value): return .bit32(value.byteSwapped)
+        case let .bit128(value): return .bit128(value.byteSwapped)
         }
     }
 }

    }
}

// MARK: - CoreBluetooth Conversion

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
    
    import CoreBluetooth
    
    public extension BluetoothUUID {
        
        public init(coreBluetooth: CBUUID) {
                        
            guard let uuid = BluetoothUUID(data: coreBluetooth.data)
                else { fatalError("Could not create Bluetooth UUID from \(coreBluetooth)") }
            
            // CBUUID is always big endian
            self.init(bigEndian: uuid)
        }
        
        public func toCoreBluetooth() -> CBUUID {
            
            let coreBluetooth = CBUUID(data: self.bigEndian.data)
            
            return coreBluetooth
        }
    }
    
#endif


// MARK: - DataConvertible

internal extension BluetoothUUID {
    
    /// Number of bytes to represent Bluetooth UUID.
    enum Length: Int {
        
        case bit16 = 2
        case bit32 = 4
        case bit128 = 16
    }
    
    private var length: Length {
        
        switch self {
        case .bit16: return .bit16
        case .bit32: return .bit32
        case .bit128: return .bit128
        }
    }
}

public extension BluetoothUUID {
    
   public init?(data: Data) {
    
        guard let length = Length(rawValue: data.count)
            else { return nil }
        
        switch length {
            
        // 16 bit
        case .bit16:
            
            let value = UInt16(bytes: (data[0], data[1]))
            self = .bit16(value)
            
        // 32 bit
        case .bit32:
            
            let value = UInt32(bytes: (data[0], data[1], data[2], data[3]))
            self = .bit32(value)
            
        // 128 bit
        case .bit128:
            
            let value = UInt128(bytes: (data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15]))
            self = .bit128(value)
        }
    }
    
    public var data: Data {
        
        return Data(self)
    }
}

extension BluetoothUUID: DataConvertible {
    
    var dataLength: Int {
        
        return length.rawValue
    }
    
    static func += (data: inout Data, value: BluetoothUUID) {
        
        switch value {
        case let .bit16(value): data += value
        case let .bit32(value): data += value
        case let .bit128(value): data += value
        }
    }
}
