فهرست منبع

Address SonarLint findings in JniMethod class

Patrick-Christopher Mattulat 1 سال پیش
والد
کامیت
a26e55b552
2فایلهای تغییر یافته به همراه13 افزوده شده و 13 حذف شده
  1. 6 5
      include/ls-std/core/jni/JniMethod.hpp
  2. 7 8
      source/ls-std/core/jni/JniMethod.cpp

+ 6 - 5
include/ls-std/core/jni/JniMethod.hpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-04-08
 * Created:         2023-04-08
-* Changed:         2023-04-10
+* Changed:         2023-05-16
 *
 *
 * */
 * */
 
 
@@ -13,6 +13,7 @@
 #include <jni.h>
 #include <jni.h>
 #include <ls-std/os/dynamic-goal.hpp>
 #include <ls-std/os/dynamic-goal.hpp>
 #include <string>
 #include <string>
+#include <string_view>
 
 
 namespace ls::std::core::experimental
 namespace ls::std::core::experimental
 {
 {
@@ -24,11 +25,11 @@ namespace ls::std::core::experimental
       ~JniMethod();
       ~JniMethod();
 
 
       [[nodiscard]] jmethodID getMethodId();
       [[nodiscard]] jmethodID getMethodId();
-      [[nodiscard]] ::std::string getMethodIdentifier();
-      [[nodiscard]] ::std::string getMethodSignature();
+      [[nodiscard]] ::std::string getMethodIdentifier() const;
+      [[nodiscard]] ::std::string getMethodSignature() const;
       void setMethodId(jmethodID _methodId);
       void setMethodId(jmethodID _methodId);
-      void setMethodIdentifier(const ::std::string &_methodIdentifier);
-      void setMethodSignature(const ::std::string &_methodSignature);
+      void setMethodIdentifier(::std::string_view _methodIdentifier);
+      void setMethodSignature(::std::string_view _methodSignature);
 
 
     private:
     private:
 
 

+ 7 - 8
source/ls-std/core/jni/JniMethod.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-04-08
 * Created:         2023-04-08
-* Changed:         2023-04-10
+* Changed:         2023-05-16
 *
 *
 * */
 * */
 
 
@@ -13,13 +13,12 @@
 using ls::std::core::EmptyStringArgumentEvaluator;
 using ls::std::core::EmptyStringArgumentEvaluator;
 using ls::std::core::experimental::JniMethod;
 using ls::std::core::experimental::JniMethod;
 using std::string;
 using std::string;
+using std::string_view;
 
 
-JniMethod::JniMethod(const string &_methodIdentifier, const string &_methodSignature)
+JniMethod::JniMethod(const string &_methodIdentifier, const string &_methodSignature) : methodIdentifier(_methodIdentifier), methodSignature(_methodSignature)
 {
 {
   EmptyStringArgumentEvaluator{_methodIdentifier, "no method identifier has been provided!"}.evaluate();
   EmptyStringArgumentEvaluator{_methodIdentifier, "no method identifier has been provided!"}.evaluate();
   EmptyStringArgumentEvaluator{_methodSignature, "no method signature has been provided!"}.evaluate();
   EmptyStringArgumentEvaluator{_methodSignature, "no method signature has been provided!"}.evaluate();
-  this->methodIdentifier = _methodIdentifier;
-  this->methodSignature = _methodSignature;
 }
 }
 
 
 JniMethod::~JniMethod() = default;
 JniMethod::~JniMethod() = default;
@@ -29,12 +28,12 @@ jmethodID JniMethod::getMethodId()
   return this->methodId;
   return this->methodId;
 }
 }
 
 
-string JniMethod::getMethodIdentifier()
+string JniMethod::getMethodIdentifier() const
 {
 {
   return this->methodIdentifier;
   return this->methodIdentifier;
 }
 }
 
 
-string JniMethod::getMethodSignature()
+string JniMethod::getMethodSignature() const
 {
 {
   return this->methodSignature;
   return this->methodSignature;
 }
 }
@@ -44,12 +43,12 @@ void JniMethod::setMethodId(jmethodID _methodId)
   this->methodId = _methodId;
   this->methodId = _methodId;
 }
 }
 
 
-void JniMethod::setMethodIdentifier(const string &_methodIdentifier)
+void JniMethod::setMethodIdentifier(string_view _methodIdentifier)
 {
 {
   this->methodIdentifier = _methodIdentifier;
   this->methodIdentifier = _methodIdentifier;
 }
 }
 
 
-void JniMethod::setMethodSignature(const string &_methodSignature)
+void JniMethod::setMethodSignature(string_view _methodSignature)
 {
 {
   this->methodSignature = _methodSignature;
   this->methodSignature = _methodSignature;
 }
 }