NullPointerArgumentEvaluator.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-08
  6. * Changed: 2023-02-08
  7. *
  8. * */
  9. #include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
  10. #include <ls-std/core/exception/IllegalArgumentException.hpp>
  11. ls::std::core::NullPointerArgumentEvaluator::NullPointerArgumentEvaluator(const ::std::shared_ptr<void> &_argument) : argument(_argument)
  12. {}
  13. ls::std::core::NullPointerArgumentEvaluator::NullPointerArgumentEvaluator(const ::std::shared_ptr<void> &_argument, ::std::string _message) : argument(_argument), message(::std::move(_message))
  14. {}
  15. ls::std::core::NullPointerArgumentEvaluator::~NullPointerArgumentEvaluator() = default;
  16. void ls::std::core::NullPointerArgumentEvaluator::evaluate()
  17. {
  18. if (this->argument == nullptr)
  19. {
  20. if (this->message.empty())
  21. {
  22. throw ls::std::core::IllegalArgumentException{"passed argument is null!"};
  23. }
  24. else
  25. {
  26. throw ls::std::core::IllegalArgumentException{this->message};
  27. }
  28. }
  29. }