// Generated by Create API
// https://github.com/CreateAPI/CreateAPI

import Foundation

public struct MatrixParam: Codable, Equatable {
    public var fieldName: String
    public var max: Max?
    public var min: Min?
    public var type: `Type`

    public struct Max: Codable, Equatable {
        public var int: Int?
        public var double: Double?

        public init(int: Int? = nil, double: Double? = nil) {
            self.int = int
            self.double = double
        }

        public init(from decoder: Decoder) throws {
            let container = try decoder.singleValueContainer()
            self.int = try? container.decode(Int.self)
            self.double = try? container.decode(Double.self)
        }

        public func encode(to encoder: Encoder) throws {
            var container = encoder.singleValueContainer()
            if let value = int { try container.encode(value) }
            if let value = double { try container.encode(value) }
        }
    }

    public struct Min: Codable, Equatable {
        public var int: Int?
        public var double: Double?

        public init(int: Int? = nil, double: Double? = nil) {
            self.int = int
            self.double = double
        }

        public init(from decoder: Decoder) throws {
            let container = try decoder.singleValueContainer()
            self.int = try? container.decode(Int.self)
            self.double = try? container.decode(Double.self)
        }

        public func encode(to encoder: Encoder) throws {
            var container = encoder.singleValueContainer()
            if let value = int { try container.encode(value) }
            if let value = double { try container.encode(value) }
        }
    }

    /// Type
    public struct `Type`: RawRepresentable, Codable, Equatable {
        public let rawValue: String

        public init(rawValue: String) {
            self.rawValue = rawValue
        }

        public static let float = Self(rawValue: "float")
        public static let int = Self(rawValue: "int")
    }

    public init(fieldName: String, max: Max? = nil, min: Min? = nil, type: `Type`) {
        self.fieldName = fieldName
        self.max = max
        self.min = min
        self.type = type
    }
}
