NullPointerArgumentEvaluator.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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-23
  7. *
  8. * */
  9. #include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
  10. #include <ls-std/core/exception/IllegalArgumentException.hpp>
  11. using ls::std::core::IllegalArgumentException;
  12. using ls::std::core::NullPointerArgumentEvaluator;
  13. using std::move;
  14. using std::shared_ptr;
  15. using std::string;
  16. NullPointerArgumentEvaluator::NullPointerArgumentEvaluator(const shared_ptr<void> &_argument) : argument(_argument)
  17. {}
  18. NullPointerArgumentEvaluator::NullPointerArgumentEvaluator(const shared_ptr<void> &_argument, string _message) : argument(_argument), message(::move(_message))
  19. {}
  20. NullPointerArgumentEvaluator::~NullPointerArgumentEvaluator() noexcept = default;
  21. void NullPointerArgumentEvaluator::evaluate()
  22. {
  23. if (this->argument == nullptr)
  24. {
  25. if (this->message.empty())
  26. {
  27. throw IllegalArgumentException{"passed argument is null!"};
  28. }
  29. else
  30. {
  31. throw IllegalArgumentException{this->message};
  32. }
  33. }
  34. }