jsdw_ios/QuickLocation/Plugin/NotEmpty.swift

51 lines
1.1 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// NotEmpty.swift
// DLSDK
//
// Created by osell on 2023/11/17.
//
import Foundation
import Moya
public protocol NotEmptyProtocol {
///
var isNotEmpty: Bool { get }
}
public extension NotEmptyProtocol {
var isNotEmpty: Bool { true }
}
///
/// - Parameter objcet: TNotEmptyProtocol
/// - Returns: truefalse
@discardableResult
public func NotEmpty<T: NotEmptyProtocol>(_ objcet: T?) -> Bool {
objcet?.isNotEmpty ?? false
}
extension String: NotEmptyProtocol {
public var isNotEmpty: Bool { trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false }
}
extension Array: NotEmptyProtocol {
public var isNotEmpty: Bool { count > 0 }
}
extension Dictionary: NotEmptyProtocol {
public var isNotEmpty: Bool { count > 0 }
}
extension Set: NotEmptyProtocol {
public var isNotEmpty: Bool { count > 0 }
}
extension NSObject: NotEmptyProtocol {}
extension Int: NotEmptyProtocol {}
extension Float: NotEmptyProtocol {}
extension Double: NotEmptyProtocol {}
extension CGFloat: NotEmptyProtocol {}
extension Response: NotEmptyProtocol {}