From 4fc0bccca9e71023ce7d0d0ce26bcbf1466e3b17 Mon Sep 17 00:00:00 2001 From: Osiris-Team Date: Sat, 5 Aug 2023 14:33:30 +0200 Subject: [PATCH] isReturnDefaultWhenValueIsNullEnabled now also affects getValues() --- src/main/java/com/osiris/dyml/Yaml.java | 3 ++- src/main/java/com/osiris/dyml/YamlSection.java | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/osiris/dyml/Yaml.java b/src/main/java/com/osiris/dyml/Yaml.java index 5877d73..7571f61 100644 --- a/src/main/java/com/osiris/dyml/Yaml.java +++ b/src/main/java/com/osiris/dyml/Yaml.java @@ -115,7 +115,8 @@ public class Yaml { /** * Enabled by default.
* Null values return their default values as fallback.
- * See {@link YamlSection#getValueAt(int)} for details. + * See {@link YamlSection#getValueAt(int)} for details.
+ * Note that this also relevant when returning all values via {@link YamlSection#getValues()}. */ public boolean isReturnDefaultWhenValueIsNullEnabled = true; /** diff --git a/src/main/java/com/osiris/dyml/YamlSection.java b/src/main/java/com/osiris/dyml/YamlSection.java index 76af5f3..641b8f2 100644 --- a/src/main/java/com/osiris/dyml/YamlSection.java +++ b/src/main/java/com/osiris/dyml/YamlSection.java @@ -360,7 +360,13 @@ public SmartString getValueAt(int i) { return v; } + /** + * Returns the values or + * default values, if values is empty and {@link Yaml#isReturnDefaultWhenValueIsNullEnabled()} is set to true. + */ public List getValues() { + if (values.isEmpty() && yaml.isReturnDefaultWhenValueIsNullEnabled) + return getDefValues(); return values; }