Skip to content

Commit

Permalink
isReturnDefaultWhenValueIsNullEnabled now also affects getValues()
Browse files Browse the repository at this point in the history
  • Loading branch information
Osiris-Team committed Aug 5, 2023
1 parent e0c05d9 commit 4fc0bcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/com/osiris/dyml/Yaml.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public class Yaml {
/**
* Enabled by default. <br>
* Null values return their default values as fallback.<br>
* See {@link YamlSection#getValueAt(int)} for details.
* See {@link YamlSection#getValueAt(int)} for details. <br>
* Note that this also relevant when returning all values via {@link YamlSection#getValues()}.
*/
public boolean isReturnDefaultWhenValueIsNullEnabled = true;
/**
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/osiris/dyml/YamlSection.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<SmartString> getValues() {
if (values.isEmpty() && yaml.isReturnDefaultWhenValueIsNullEnabled)
return getDefValues();
return values;
}

Expand Down

0 comments on commit 4fc0bcc

Please sign in to comment.