-- Copyright (c) 2026 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at:
--          http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.
local validate = require 'mc.validate'
local utils = require 'mc.utils'

local MBmcStartFlag = {}

---@class MBmcStartFlag.Value
---@field Value integer
local TValue = {}
TValue.__index = TValue
TValue.group = {}

local function TValue_from_obj(obj)
    return setmetatable(obj, TValue)
end

function TValue.new(Value)
    return TValue_from_obj({Value = Value or 255})
end
---@param obj MBmcStartFlag.Value
function TValue:init_from_obj(obj)
    self.Value = obj.Value or 255
end

function TValue:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TValue.group)
end

TValue.from_obj = TValue_from_obj

TValue.proto_property = {'Value'}

TValue.default = {0}

TValue.struct = {{name = 'Value', is_array = false, struct = nil}}

function TValue:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Value', self.Value, 'uint8', false, errs, need_convert)

    TValue:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TValue.proto_property, errs, need_convert)
    return self
end

function TValue:unpack(_)
    return self.Value
end

MBmcStartFlag.Value = TValue

return MBmcStartFlag
