From c5715a82109047d2c1a12ecf02ad724542136418 Mon Sep 17 00:00:00 2001 From: Leonhard Date: Wed, 15 Jul 2020 21:07:43 +0200 Subject: [PATCH] Smaller updates --- .../storage/internal/editor/yaml/YamlParser.java | 9 +++++---- .../java/de/leonhard/storage/util/FileUtils.java | 12 +++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/leonhard/storage/internal/editor/yaml/YamlParser.java b/src/main/java/de/leonhard/storage/internal/editor/yaml/YamlParser.java index 2c7b4bdf..d0b2aba9 100755 --- a/src/main/java/de/leonhard/storage/internal/editor/yaml/YamlParser.java +++ b/src/main/java/de/leonhard/storage/internal/editor/yaml/YamlParser.java @@ -66,17 +66,18 @@ public Map> assignCommentsToKey(final List lines) { String currentKey = FOOTER; for (int i = lines.size() - 1; i >= 0; i--) { final String line = lines.get(i); - if (line.trim().startsWith("#") || line.isEmpty()) { + if (!line.trim().startsWith("#") && !line.isEmpty()) { + currentKey = line; + } else { final List storage = out.get(currentKey.split(":")[0]); if (storage == null) { - out.put(currentKey.split(":")[0], + out.put( + currentKey.split(":")[0], new ArrayList<>(Collections.singletonList(line))); } else { storage.add(line); } - } else { - currentKey = line; } } return out; diff --git a/src/main/java/de/leonhard/storage/util/FileUtils.java b/src/main/java/de/leonhard/storage/util/FileUtils.java index 71a4234a..22936bc5 100755 --- a/src/main/java/de/leonhard/storage/util/FileUtils.java +++ b/src/main/java/de/leonhard/storage/util/FileUtils.java @@ -1,6 +1,12 @@ package de.leonhard.storage.util; import de.leonhard.storage.internal.provider.LightningProviders; +import lombok.Cleanup; +import lombok.NonNull; +import lombok.SneakyThrows; +import lombok.experimental.UtilityClass; +import org.jetbrains.annotations.Nullable; + import java.io.*; import java.nio.file.Files; import java.nio.file.Path; @@ -12,10 +18,6 @@ import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import lombok.Cleanup; -import lombok.NonNull; -import lombok.SneakyThrows; -import lombok.experimental.UtilityClass; /** * Class for easier, more convenient & strait interaction with files @@ -42,7 +44,7 @@ public List listFiles(@NonNull final File folder) { */ public List listFiles( @NonNull final File folder, - @NonNull final String extension) { + @Nullable final String extension) { final List result = new ArrayList<>(); final File[] files = folder.listFiles();