/**
 * Namf_Communication
 * AMF Communication Service © 2019, 3GPP Organizational Partners (ARIB, ATIS,
 * CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
 *
 * The version of the OpenAPI document: 1.1.0.alpha-1
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator
 * (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
 * the class manually.
 */

#include "Snssai.h"
#include "Helpers.h"

#include <sstream>

namespace oai {
namespace amf {
namespace model {

Snssai::Snssai() {
  m_Sst     = 0;
  m_Sd      = "";
  m_SdIsSet = false;
}

void Snssai::validate() const {
  std::stringstream msg;
  // if (!validate(msg))
  // {
  //     throw oai::nssf_server::helpers::ValidationException(msg.str());
  // }
}

bool Snssai::validate(std::stringstream& msg) const {
  return validate(msg, "");
}

bool Snssai::validate(
    std::stringstream& msg, const std::string& pathPrefix) const {
  bool success                  = true;
  const std::string _pathPrefix = pathPrefix.empty() ? "Snssai" : pathPrefix;

  /* Sst */ {
    const int32_t& value               = m_Sst;
    const std::string currentValuePath = _pathPrefix + ".sst";

    if (value < 0) {
      success = false;
      msg << currentValuePath << ": must be greater than or equal to 0;";
    }
    if (value > 255) {
      success = false;
      msg << currentValuePath << ": must be less than or equal to 255;";
    }
  }

  if (sdIsSet()) {
    const std::string& value           = m_Sd;
    const std::string currentValuePath = _pathPrefix + ".sd";
  }

  return success;
}

bool Snssai::operator==(const Snssai& rhs) const {
  return

      (getSst() == rhs.getSst()) &&

      ((!sdIsSet() && !rhs.sdIsSet()) ||
       (sdIsSet() && rhs.sdIsSet() && getSd() == rhs.getSd()))

          ;
}

bool Snssai::operator!=(const Snssai& rhs) const {
  return !(*this == rhs);
}

void to_json(nlohmann::json& j, const Snssai& o) {
  j        = nlohmann::json();
  j["sst"] = o.m_Sst;
  if (o.sdIsSet()) j["sd"] = o.m_Sd;
}

void from_json(const nlohmann::json& j, Snssai& o) {
  j.at("sst").get_to(o.m_Sst);
  if (j.find("sd") != j.end()) {
    j.at("sd").get_to(o.m_Sd);
    o.m_SdIsSet = true;
  }
}

int32_t Snssai::getSst() const {
  return m_Sst;
}
void Snssai::setSst(int32_t const value) {
  m_Sst = value;
}
std::string Snssai::getSd() const {
  return m_Sd;
}
void Snssai::setSd(std::string const& value) {
  m_Sd      = value;
  m_SdIsSet = true;
}
bool Snssai::sdIsSet() const {
  return m_SdIsSet;
}
void Snssai::unsetSd() {
  m_SdIsSet = false;
}

}  // namespace model
}  // namespace amf
}  // namespace oai
