mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
65 lines
1.9 KiB
Swift
65 lines
1.9 KiB
Swift
// Generated code. Do not modify.
|
|
|
|
import Foundation
|
|
import Serialization
|
|
import VGSL
|
|
|
|
@frozen
|
|
public enum DivInputMask: Sendable {
|
|
case divFixedLengthInputMask(DivFixedLengthInputMask)
|
|
case divCurrencyInputMask(DivCurrencyInputMask)
|
|
case divPhoneInputMask(DivPhoneInputMask)
|
|
|
|
public var value: Serializable & DivInputMaskBase {
|
|
switch self {
|
|
case let .divFixedLengthInputMask(value):
|
|
return value
|
|
case let .divCurrencyInputMask(value):
|
|
return value
|
|
case let .divPhoneInputMask(value):
|
|
return value
|
|
}
|
|
}
|
|
}
|
|
|
|
extension DivInputMask {
|
|
public init(dictionary: [String: Any], context: ParsingContext) throws {
|
|
let dictionary = context.templateResolver?(dictionary) ?? dictionary
|
|
let blockType = try dictionary.getField("type") as String
|
|
switch blockType {
|
|
case DivFixedLengthInputMask.type:
|
|
self = .divFixedLengthInputMask(try DivFixedLengthInputMask(dictionary: dictionary, context: context))
|
|
case DivCurrencyInputMask.type:
|
|
self = .divCurrencyInputMask(try DivCurrencyInputMask(dictionary: dictionary, context: context))
|
|
case DivPhoneInputMask.type:
|
|
self = .divPhoneInputMask(try DivPhoneInputMask(dictionary: dictionary, context: context))
|
|
default:
|
|
throw DeserializationError.requiredFieldIsMissing(field: "type")
|
|
}
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
extension DivInputMask: Equatable {
|
|
public static func ==(lhs: DivInputMask, rhs: DivInputMask) -> Bool {
|
|
switch (lhs, rhs) {
|
|
case let (.divFixedLengthInputMask(l), .divFixedLengthInputMask(r)):
|
|
return l == r
|
|
case let (.divCurrencyInputMask(l), .divCurrencyInputMask(r)):
|
|
return l == r
|
|
case let (.divPhoneInputMask(l), .divPhoneInputMask(r)):
|
|
return l == r
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
|
|
extension DivInputMask: Serializable {
|
|
@_optimize(size)
|
|
public func toDictionary() -> [String: ValidSerializationValue] {
|
|
return value.toDictionary()
|
|
}
|
|
}
|