/**
 * linglong仓库
 * 玲珑仓库接口
 *
 * The version of the OpenAPI document: 1.0.0
 * Contact: wurongjie@deepin.org
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

#include "Schema_RepoInfo.h"

#include <QDebug>
#include <QJsonArray>
#include <QJsonDocument>
#include <QObject>

#include "Helpers.h"

namespace linglong {
namespace api {
namespace client {

Schema_RepoInfo::Schema_RepoInfo(QString json) {
    this->initializeModel();
    this->fromJson(json);
}

Schema_RepoInfo::Schema_RepoInfo() {
    this->initializeModel();
}

Schema_RepoInfo::~Schema_RepoInfo() {}

void Schema_RepoInfo::initializeModel() {

    m_mode_isSet = false;
    m_mode_isValid = false;

    m_name_isSet = false;
    m_name_isValid = false;

    m_refs_isSet = false;
    m_refs_isValid = false;
}

void Schema_RepoInfo::fromJson(QString jsonString) {
    QByteArray array(jsonString.toStdString().c_str());
    QJsonDocument doc = QJsonDocument::fromJson(array);
    QJsonObject jsonObject = doc.object();
    this->fromJsonObject(jsonObject);
}

void Schema_RepoInfo::fromJsonObject(QJsonObject json) {

    m_mode_isValid = ::linglong::api::client::fromJsonValue(m_mode, json[QString("mode")]);
    m_mode_isSet = !json[QString("mode")].isNull() && m_mode_isValid;

    m_name_isValid = ::linglong::api::client::fromJsonValue(m_name, json[QString("name")]);
    m_name_isSet = !json[QString("name")].isNull() && m_name_isValid;

    m_refs_isValid = ::linglong::api::client::fromJsonValue(m_refs, json[QString("refs")]);
    m_refs_isSet = !json[QString("refs")].isNull() && m_refs_isValid;
}

QString Schema_RepoInfo::asJson() const {
    QJsonObject obj = this->asJsonObject();
    QJsonDocument doc(obj);
    QByteArray bytes = doc.toJson();
    return QString(bytes);
}

QJsonObject Schema_RepoInfo::asJsonObject() const {
    QJsonObject obj;
    if (m_mode_isSet) {
        obj.insert(QString("mode"), ::linglong::api::client::toJsonValue(m_mode));
    }
    if (m_name_isSet) {
        obj.insert(QString("name"), ::linglong::api::client::toJsonValue(m_name));
    }
    if (m_refs.size() > 0) {
        obj.insert(QString("refs"), ::linglong::api::client::toJsonValue(m_refs));
    }
    return obj;
}

QString Schema_RepoInfo::getMode() const {
    return m_mode;
}
void Schema_RepoInfo::setMode(const QString &mode) {
    m_mode = mode;
    m_mode_isSet = true;
}

bool Schema_RepoInfo::is_mode_Set() const{
    return m_mode_isSet;
}

bool Schema_RepoInfo::is_mode_Valid() const{
    return m_mode_isValid;
}

QString Schema_RepoInfo::getName() const {
    return m_name;
}
void Schema_RepoInfo::setName(const QString &name) {
    m_name = name;
    m_name_isSet = true;
}

bool Schema_RepoInfo::is_name_Set() const{
    return m_name_isSet;
}

bool Schema_RepoInfo::is_name_Valid() const{
    return m_name_isValid;
}

QList<QString> Schema_RepoInfo::getRefs() const {
    return m_refs;
}
void Schema_RepoInfo::setRefs(const QList<QString> &refs) {
    m_refs = refs;
    m_refs_isSet = true;
}

bool Schema_RepoInfo::is_refs_Set() const{
    return m_refs_isSet;
}

bool Schema_RepoInfo::is_refs_Valid() const{
    return m_refs_isValid;
}

bool Schema_RepoInfo::isSet() const {
    bool isObjectUpdated = false;
    do {
        if (m_mode_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (m_name_isSet) {
            isObjectUpdated = true;
            break;
        }

        if (m_refs.size() > 0) {
            isObjectUpdated = true;
            break;
        }
    } while (false);
    return isObjectUpdated;
}

bool Schema_RepoInfo::isValid() const {
    // only required properties are required for the object to be considered valid
    return true;
}

} // namespace linglong
} // namespace api
} // namespace client
