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

#ifndef LS_STD_RAW_NULL_POINTER_ARGUMENT_EVALUATOR_HPP
#define LS_STD_RAW_NULL_POINTER_ARGUMENT_EVALUATOR_HPP

#include <ls-std/core/exception/IllegalArgumentException.hpp>
#include <ls-std/core/interface/IEvaluator.hpp>
#include <ls-std/core/type/RawPointer.hpp>
#include <string>

/*
 * @doc: class(name: 'RawNullPointerArgumentEvaluator', package: 'core')
 * @doc: core.RawNullPointerArgumentEvaluator.description('This class evaluates whether a passed raw pointer argument is null.')
 * */

namespace ls::standard::core
{
  template<typename T>
  class RawNullPointerArgumentEvaluator : public ls::standard::core::interface_type::IEvaluator
  {
    public:

      explicit RawNullPointerArgumentEvaluator(const ls::standard::core::type::RawPointer<T> &_argument) : argument(_argument)
      {}
      explicit RawNullPointerArgumentEvaluator(const ls::standard::core::type::RawPointer<T> &_argument, const ::std::string &_message) : argument(_argument), message(_message)
      {}
      ~RawNullPointerArgumentEvaluator() noexcept override = default;

      void evaluate() override
      {
        if (this->argument.get() == nullptr)
        {
          if (this->message.empty())
          {
            throw ls::standard::core::IllegalArgumentException{"passed argument is null!"};
          }
          else
          {
            throw ls::standard::core::IllegalArgumentException{this->message};
          }
        }
      }

    private:

      ls::standard::core::type::RawPointer<T> argument{};
      ::std::string message{};
  };
}

#endif
