You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2019/01/09 16:35:42 UTC

[GitHub] arpadboda commented on a change in pull request #460: MINIFICPP-479: Add processor property descriptor updates with c2 validation

arpadboda commented on a change in pull request #460: MINIFICPP-479: Add processor property descriptor updates with c2 validation
URL: https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r246434451
 
 

 ##########
 File path: libminifi/include/core/Property.h
 ##########
 @@ -129,21 +102,72 @@ class Property {
   std::string getDisplayName() const;
   std::vector<std::string> getAllowedTypes() const;
   std::string getDescription() const;
-  std::string getValue() const;
+  std::shared_ptr<PropertyValidator> getValidator() const;
+  const PropertyValue &getValue() const;
   bool getRequired() const;
   bool supportsExpressionLangauge() const;
   std::string getValidRegex() const;
   std::vector<std::string> getDependentProperties() const;
   std::vector<std::pair<std::string, std::string>> getExclusiveOfProperties() const;
-  std::vector<std::string> &getValues();
+  std::vector<std::string> getValues();
+
+  const PropertyValue &getDefaultValue() const {
+    return default_value_;
+  }
+
+  template<typename T = std::string>
+  void setValue(const T &value) {
+    PropertyValue vn = default_value_;
+    vn = value;
+    if (validator_) {
+      vn.setValidator(validator_);
+      ValidationResult result = validator_->validate(name_, vn.getValue());
+      if (!result.valid()) {
+        // throw some exception?
+      }
+    } else {
+      vn.setValidator(core::StandardValidators::VALID);
+    }
+    if (!is_collection_) {
+      values_.clear();
+      values_.push_back(vn);
+    } else {
+      values_.push_back(vn);
+    }
+  }
 
-  void setValue(std::string value);
+  void setValue(PropertyValue &vn) {
+    if (validator_) {
+      vn.setValidator(validator_);
+      ValidationResult result = validator_->validate(name_, vn.getValue());
+      if (!result.valid()) {
+        // throw some exception?
+      }
+    } else {
+      vn.setValidator(core::StandardValidators::VALID);
+    }
+    if (!is_collection_) {
+      values_.clear();
+      values_.push_back(vn);
+    } else {
 
 Review comment:
   Same here. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services