// Generated code. Do not modify. @testable import DivKit import Foundation import Serialization import VGSL import enum DivKit.Expression public final class EntityWithSimpleProperties: EntityProtocol, Sendable { public static let type: String = "entity_with_simple_properties" public let boolean: Expression? public let booleanInt: Expression? public let color: Expression? public let double: Expression? public let id: Int // default value: 0 public let integer: Expression // default value: 0 public let positiveInteger: Expression? // constraint: number > 0 public let string: Expression? public let url: Expression? public func resolveBoolean(_ resolver: ExpressionResolver) -> Bool? { resolver.resolveNumeric(boolean) } public func resolveBooleanInt(_ resolver: ExpressionResolver) -> Bool? { resolver.resolveNumeric(booleanInt) } public func resolveColor(_ resolver: ExpressionResolver) -> Color? { resolver.resolveColor(color) } public func resolveDouble(_ resolver: ExpressionResolver) -> Double? { resolver.resolveNumeric(double) } public func resolveInteger(_ resolver: ExpressionResolver) -> Int { resolver.resolveNumeric(integer) ?? 0 } public func resolvePositiveInteger(_ resolver: ExpressionResolver) -> Int? { resolver.resolveNumeric(positiveInteger) } public func resolveString(_ resolver: ExpressionResolver) -> String? { resolver.resolveString(string) } public func resolveUrl(_ resolver: ExpressionResolver) -> URL? { resolver.resolveUrl(url) } static let positiveIntegerValidator: AnyValueValidator = makeValueValidator(valueValidator: { $0 > 0 }) public convenience init(dictionary: [String: Any], context: ParsingContext) throws { self.init( boolean: try dictionary.getOptionalExpressionField("boolean", context: context), booleanInt: try dictionary.getOptionalExpressionField("boolean_int", context: context), color: try dictionary.getOptionalExpressionField("color", transform: Color.color(withHexString:), context: context), double: try dictionary.getOptionalExpressionField("double", context: context), id: try dictionary.getOptionalField("id", context: context), integer: try dictionary.getOptionalExpressionField("integer", context: context), positiveInteger: try dictionary.getOptionalExpressionField("positive_integer", validator: Self.positiveIntegerValidator, context: context), string: try dictionary.getOptionalExpressionField("string", context: context), url: try dictionary.getOptionalExpressionField("url", transform: URL.makeFromNonEncodedString, context: context) ) } init( boolean: Expression? = nil, booleanInt: Expression? = nil, color: Expression? = nil, double: Expression? = nil, id: Int? = nil, integer: Expression? = nil, positiveInteger: Expression? = nil, string: Expression? = nil, url: Expression? = nil ) { self.boolean = boolean self.booleanInt = booleanInt self.color = color self.double = double self.id = id ?? 0 self.integer = integer ?? .value(0) self.positiveInteger = positiveInteger self.string = string self.url = url } } #if DEBUG extension EntityWithSimpleProperties: Equatable { public static func ==(lhs: EntityWithSimpleProperties, rhs: EntityWithSimpleProperties) -> Bool { guard lhs.boolean == rhs.boolean, lhs.booleanInt == rhs.booleanInt, lhs.color == rhs.color else { return false } guard lhs.double == rhs.double, lhs.id == rhs.id, lhs.integer == rhs.integer else { return false } guard lhs.positiveInteger == rhs.positiveInteger, lhs.string == rhs.string, lhs.url == rhs.url else { return false } return true } } #endif extension EntityWithSimpleProperties: Serializable { @_optimize(size) public func toDictionary() -> [String: ValidSerializationValue] { var result: [String: ValidSerializationValue] = [:] result["type"] = Self.type result["boolean"] = boolean?.toValidSerializationValue() result["boolean_int"] = booleanInt?.toValidSerializationValue() result["color"] = color?.toValidSerializationValue() result["double"] = double?.toValidSerializationValue() result["id"] = id result["integer"] = integer.toValidSerializationValue() result["positive_integer"] = positiveInteger?.toValidSerializationValue() result["string"] = string?.toValidSerializationValue() result["url"] = url?.toValidSerializationValue() return result } }