mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
60 lines
1.6 KiB
Swift
60 lines
1.6 KiB
Swift
// Generated code. Do not modify.
|
|
|
|
import Foundation
|
|
import Serialization
|
|
import VGSL
|
|
|
|
public final class DivActionSetState: Sendable {
|
|
public static let type: String = "set_state"
|
|
public let stateId: Expression<String>
|
|
public let temporary: Expression<Bool> // default value: true
|
|
|
|
public func resolveStateId(_ resolver: ExpressionResolver) -> String? {
|
|
resolver.resolveString(stateId)
|
|
}
|
|
|
|
public func resolveTemporary(_ resolver: ExpressionResolver) -> Bool {
|
|
resolver.resolveNumeric(temporary) ?? true
|
|
}
|
|
|
|
public convenience init(dictionary: [String: Any], context: ParsingContext) throws {
|
|
self.init(
|
|
stateId: try dictionary.getExpressionField("state_id", context: context),
|
|
temporary: try dictionary.getOptionalExpressionField("temporary", context: context)
|
|
)
|
|
}
|
|
|
|
init(
|
|
stateId: Expression<String>,
|
|
temporary: Expression<Bool>? = nil
|
|
) {
|
|
self.stateId = stateId
|
|
self.temporary = temporary ?? .value(true)
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
extension DivActionSetState: Equatable {
|
|
public static func ==(lhs: DivActionSetState, rhs: DivActionSetState) -> Bool {
|
|
guard
|
|
lhs.stateId == rhs.stateId,
|
|
lhs.temporary == rhs.temporary
|
|
else {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
}
|
|
#endif
|
|
|
|
extension DivActionSetState: Serializable {
|
|
@_optimize(size)
|
|
public func toDictionary() -> [String: ValidSerializationValue] {
|
|
var result: [String: ValidSerializationValue] = [:]
|
|
result["type"] = Self.type
|
|
result["state_id"] = stateId.toValidSerializationValue()
|
|
result["temporary"] = temporary.toValidSerializationValue()
|
|
return result
|
|
}
|
|
}
|