Repository: decorators-squad/eo-yaml (java)

Issue:
Empty lines of list are converting into null
```
// with space or empty doesn't matter.
" ",
"&7Right Click to delete this fake player.",
"&7Left Click to teleport this fake player.",
"&7Middle Click to toggle visible this fake player."
````
It's converting into;
```yml
lore:
  - null
  - "&7Right Click to delete this fake player."
  - "&7Left Click to teleport this fake player."
  - "&7Middle Click to toggle visible this fake player."
````
and after reloading the file the result is this;
```yml
lore:
  - "&7Right Click to delete this fake player."
  - "&7Left Click to teleport this fake player."
  - "&7Middle Click to toggle visible this fake player."
````

Pull request:
Handle scalar of spaces.
Modify BaseScalar to handle escaping with a regex and support matching string of purely spaces. Fixes #376 

Patch:
diff --git a/src/main/java/com/amihaiemil/eoyaml/BaseScalar.java b/src/main/java/com/amihaiemil/eoyaml/BaseScalar.java
index f6720ac..d810bfc 100644
--- a/src/main/java/com/amihaiemil/eoyaml/BaseScalar.java
+++ b/src/main/java/com/amihaiemil/eoyaml/BaseScalar.java
@@ -109,6 +109,6 @@ abstract class BaseScalar extends BaseYamlNode implements Scalar {
 
     @Override
     final boolean isEmpty() {
-        return this.value() == null || this.value().trim().isEmpty();
+        return this.value() == null || this.value().isEmpty();
     }
 }
diff --git a/src/main/java/com/amihaiemil/eoyaml/RtYamlPrinter.java b/src/main/java/com/amihaiemil/eoyaml/RtYamlPrinter.java
index df6cc57..418b73d 100644
--- a/src/main/java/com/amihaiemil/eoyaml/RtYamlPrinter.java
+++ b/src/main/java/com/amihaiemil/eoyaml/RtYamlPrinter.java
@@ -359,11 +359,6 @@ final class RtYamlPrinter implements YamlPrinter {
      */
     static class Escaped extends BaseScalar {
 
-        /**
-         * Special chars that need escaping.
-         */
-        private final String RESERVED = "#:->|$%&{}[]";
-
         /**
          * Original unescaped scalar.
          */
@@ -380,25 +375,14 @@ final class RtYamlPrinter implements YamlPrinter {
         @Override
         public String value() {
             final String value = this.original.value();
-            String escaped = null;
-            if(value.startsWith("'") && value.endsWith("'")
-                || value.startsWith("\"") && value.endsWith("\"")
-            ) {
-                escaped = value;
-            } else {
-                for (int idx = 0; idx < value.length(); idx++){
-                    if(RESERVED.contains(
-                        String.valueOf(value.charAt(idx)))) {
-                        if(value.contains("\"")) {
-                            escaped = "'" + value + "'";
-                        } else {
-                            escaped = "\"" + value + "\"";
-                        }
-                        break;
-                    }
-                }
-                if(escaped == null) {
-                    escaped = value;
+            String escaped = value;
+            boolean quoted = (value.startsWith("'") && value.endsWith("'"))
+                    || (value.startsWith("\"") && value.endsWith("\""));
+            if (!quoted && value.matches(".*[\\-#:>|$%&{}\\[\\]]+.*|[ ]+")) {
+                if(value.contains("\"")) {
+                    escaped = "'" + value + "'";
+                } else {
+                    escaped = "\"" + value + "\"";
                 }
             }
             return escaped;


Test patch:
diff --git a/src/test/java/com/amihaiemil/eoyaml/YamlSequencePrintTest.java b/src/test/java/com/amihaiemil/eoyaml/YamlSequencePrintTest.java
index 265dbb4..359e788 100644
--- a/src/test/java/com/amihaiemil/eoyaml/YamlSequencePrintTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/YamlSequencePrintTest.java
@@ -107,6 +107,7 @@ public final class YamlSequencePrintTest {
             )
             .add(Yaml.createYamlSequenceBuilder().build())
             .add(Yaml.createYamlMappingBuilder().build())
+            .add(" ")
             .build();
         MatcherAssert.assertThat(
             built.toString(),
diff --git a/src/test/resources/printing_tests/yamlSequenceAllNodes.txt b/src/test/resources/printing_tests/yamlSequenceAllNodes.txt
index c4c544f..29be0c6 100644
--- a/src/test/resources/printing_tests/yamlSequenceAllNodes.txt
+++ b/src/test/resources/printing_tests/yamlSequenceAllNodes.txt
@@ -14,4 +14,5 @@
   - of plain scalars
   - as child
 - []
-- {}
\ No newline at end of file
+- {}
+- " "
\ No newline at end of file