sergehuber commented on code in PR #754:
URL: https://github.com/apache/unomi/pull/754#discussion_r3252435836


##########
api/src/main/java/org/apache/unomi/api/Parameter.java:
##########
@@ -62,11 +81,40 @@ public void setChoiceListInitializerFilter(String 
choiceListInitializerFilter) {
         // Avoid errors when deploying old definitions
     }
 
-    public String getDefaultValue() {
+    public Object getDefaultValue() {
         return defaultValue;
     }
 
-    public void setDefaultValue(String defaultValue) {
+    public void setDefaultValue(Object defaultValue) {
         this.defaultValue = defaultValue;
     }
+
+    /**
+     * Converts this parameter to a Map structure for YAML output.
+     * Implements YamlConvertible interface.
+     *
+     * @param visited set of already visited objects to prevent infinite 
recursion (may be null)
+     * @return a Map representation of this parameter
+     */
+    @Override
+    public Map<String, Object> toYaml(Set<Object> visited, int maxDepth) {
+        if (maxDepth <= 0) {
+            return YamlUtils.YamlMapBuilder.create()
+                .put("id", id)
+                .put("validation", "<max depth exceeded>")

Review Comment:
   Addressed by normalizing in setParameterValues(null) to an empty HashMap, 
and by making containsParameter / setParameter null-safe. That keeps the field 
non-null in normal use after setter calls while avoiding NPEs in 
equals/hashCode for the typical path. Covered in 
ConditionTest.testSetParameterValuesNullReplacesWithEmptyMap and related tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to