/*
* Author:          Patrick-Christopher Mattulat
 * Co-Author:       Claude Sonnet 4.6 (LLM)
* Company:         Lynar Studios
* E-Mail:          webmaster@lynarstudios.com
* Created:         2023-04-09
* Changed:         2026-06-23
*
* */

#include <ls-std/core/jni/JniClass.hpp>
#include <ls-std/time/common/DateParameter.hpp>
#include <ls-std/time/common/jni/JniDateParameterMapper.hpp>

using ls::standard::core::experimental::JniClass;
using ls::standard::time::DateParameter;
using ls::standard::time::experimental::JniDateParameterMapper;
using ls::standard::time::type::Day;
using ls::standard::time::type::Hour;
using ls::standard::time::type::Minute;
using ls::standard::time::type::Month;
using ls::standard::time::type::Second;

JniDateParameterMapper::JniDateParameterMapper() = default;

JniDateParameterMapper::~JniDateParameterMapper() = default;

DateParameter JniDateParameterMapper::toDateParameter(const JniClass &_javaClass)
{
  JniClass javaClass = _javaClass;
  DateParameter dateParameter{};

  dateParameter.setYear(javaClass.callMethod("getYear").getIntegerValue());
  dateParameter.setMonth(static_cast<Month>(javaClass.callMethod("getMonth").getByteValue()));
  dateParameter.setDay(static_cast<Day>(javaClass.callMethod("getDay").getByteValue()));
  dateParameter.setHour(static_cast<Hour>(javaClass.callMethod("getHour").getByteValue()));
  dateParameter.setMinute(static_cast<Minute>(javaClass.callMethod("getMinute").getByteValue()));
  dateParameter.setSecond(static_cast<Second>(javaClass.callMethod("getSecond").getByteValue()));

  return dateParameter;
}
