diff --git a/pom.xml b/pom.xml index bba654d4..0751d594 100755 --- a/pom.xml +++ b/pom.xml @@ -154,7 +154,7 @@ lombok org.projectlombok provided - 1.18.20 + 1.18.22 @@ -166,7 +166,7 @@ org.junit.jupiter junit-jupiter - 5.8.0 + 5.8.1 test diff --git a/src/main/java/de/leonhard/storage/Config.java b/src/main/java/de/leonhard/storage/Config.java index 187f794a..2a70bf2b 100755 --- a/src/main/java/de/leonhard/storage/Config.java +++ b/src/main/java/de/leonhard/storage/Config.java @@ -14,8 +14,6 @@ @SuppressWarnings({"unused"}) public class Config extends Yaml { - private List header; - public Config(@NonNull final Config config) { super(config); } diff --git a/src/main/java/de/leonhard/storage/internal/DataStorage.java b/src/main/java/de/leonhard/storage/internal/DataStorage.java index f7ac3c9f..d94402fa 100755 --- a/src/main/java/de/leonhard/storage/internal/DataStorage.java +++ b/src/main/java/de/leonhard/storage/internal/DataStorage.java @@ -319,7 +319,7 @@ default T getOrSetDefault(final String key, final T def) { set(key, def); return def; } else { - return (T) ClassWrapper.getFromDef(raw, def); + return ClassWrapper.getFromDef(raw, def); } } } diff --git a/src/main/java/de/leonhard/storage/internal/FileData.java b/src/main/java/de/leonhard/storage/internal/FileData.java index f60bb832..60f2272d 100755 --- a/src/main/java/de/leonhard/storage/internal/FileData.java +++ b/src/main/java/de/leonhard/storage/internal/FileData.java @@ -234,14 +234,13 @@ public Set keySet(final String key) { */ private Set multiLayerKeySet(final Map map) { final Set out = new HashSet<>(); - for (final String key : map.keySet()) { - if (map.get(key) instanceof Map) { - for (final String tempKey : multiLayerKeySet( - (Map) map.get(key))) { - out.add(key + "." + tempKey); + for (final Map.Entry entry : map.entrySet()) { + if (entry.getValue() instanceof Map) { + for (final String tempKey : multiLayerKeySet((Map) entry.getValue())) { + out.add(entry.getKey() + "." + tempKey); } } else { - out.add(key); + out.add(entry.getKey()); } } return out; @@ -307,9 +306,9 @@ public void putAll(final Map map) { private int size(final Map map) { int size = map.size(); - for (final String key : map.keySet()) { - if (map.get(key) instanceof Map) { - size += size((Map) map.get(key)); + for (final Map.Entry entry : map.entrySet()) { + if (entry.getValue() instanceof Map) { + size += size((Map) entry.getValue()); } } return size; diff --git a/src/main/java/de/leonhard/storage/internal/editor/toml/TomlReader.java b/src/main/java/de/leonhard/storage/internal/editor/toml/TomlReader.java index 6c2fbdd2..b175fab6 100644 --- a/src/main/java/de/leonhard/storage/internal/editor/toml/TomlReader.java +++ b/src/main/java/de/leonhard/storage/internal/editor/toml/TomlReader.java @@ -446,7 +446,9 @@ private Map nextTableContent() { } private Object nextNumberOrDate(final char first) { - boolean maybeDouble = true, maybeInteger = true, maybeDate = true; + boolean maybeDouble = true; + boolean maybeInteger = true; + boolean maybeDate = true; final StringBuilder sb = new StringBuilder(); sb.append(first); char c; @@ -614,7 +616,8 @@ private String nextBasicString() { private String nextBasicMultilineString() { final StringBuilder sb = new StringBuilder(); - boolean first = true, escape = false; + boolean first = true; + boolean escape = false; while (hasNext()) { final char c = next(); if (first && (c == '\r' || c == '\n')) { diff --git a/src/main/java/de/leonhard/storage/internal/provider/LightningProviders.java b/src/main/java/de/leonhard/storage/internal/provider/LightningProviders.java index 94f460cc..18508a99 100644 --- a/src/main/java/de/leonhard/storage/internal/provider/LightningProviders.java +++ b/src/main/java/de/leonhard/storage/internal/provider/LightningProviders.java @@ -24,44 +24,39 @@ public class LightningProviders { private ExceptionHandler exceptionHandler; public MapProvider mapProvider() { - - if (mapProvider != null) { - return mapProvider; + if (mapProvider == null) { + mapProvider = new MapProvider() {}; } - - return mapProvider = new MapProvider() { - }; + return mapProvider; } public YamlConfig yamlConfig() { - if (yamlConfig != null) { - return yamlConfig; + if (yamlConfig == null) { + final YamlConfig config = new YamlConfig(); + // Use unicode + config.writeConfig.setEscapeUnicode(false); + // Don't use anchors + config.writeConfig.setAutoAnchor(false); + // Never use write the classname above keys + config.writeConfig.setWriteClassname(YamlConfig.WriteClassName.NEVER); + yamlConfig = config; } - final YamlConfig config = new YamlConfig(); - // Use unicode - config.writeConfig.setEscapeUnicode(false); - // Don't use anchors - config.writeConfig.setAutoAnchor(false); - // Never use write the classname above keys - config.writeConfig.setWriteClassname(YamlConfig.WriteClassName.NEVER); - return yamlConfig = config; + return yamlConfig; } public InputStreamProvider inputStreamProvider() { - if (inputStreamProvider != null) { - return inputStreamProvider; + if (inputStreamProvider == null) { + inputStreamProvider = new InputStreamProvider() {}; } - return inputStreamProvider = new InputStreamProvider() { - }; + return inputStreamProvider; } public ExceptionHandler exceptionHandler() { - if (exceptionHandler != null) { - return exceptionHandler; + if (exceptionHandler == null) { + exceptionHandler = new ExceptionHandler() {}; } - return exceptionHandler = new ExceptionHandler() { - }; + return exceptionHandler; } } diff --git a/src/main/java/de/leonhard/storage/util/FileUtils.java b/src/main/java/de/leonhard/storage/util/FileUtils.java index 99fe5ce1..1e520c45 100755 --- a/src/main/java/de/leonhard/storage/util/FileUtils.java +++ b/src/main/java/de/leonhard/storage/util/FileUtils.java @@ -10,7 +10,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; diff --git a/src/test/java/de/leonhard/storage/ConfigTest.java b/src/test/java/de/leonhard/storage/ConfigTest.java index a46f8ffc..60d84b6b 100644 --- a/src/test/java/de/leonhard/storage/ConfigTest.java +++ b/src/test/java/de/leonhard/storage/ConfigTest.java @@ -77,7 +77,7 @@ void testSet() { @AfterAll @Test - static void tearDown() { + void tearDown() { config.clear(); Assertions.assertTrue(config.getFile().delete()); } diff --git a/src/test/java/de/leonhard/storage/JsonTest.java b/src/test/java/de/leonhard/storage/JsonTest.java index 7fc7fbd6..4e6d72fc 100644 --- a/src/test/java/de/leonhard/storage/JsonTest.java +++ b/src/test/java/de/leonhard/storage/JsonTest.java @@ -69,7 +69,7 @@ void testSet() { @AfterAll @Test - static void tearDown() { + void tearDown() { json.clear(); Assertions.assertTrue(json.getFile().delete()); } diff --git a/src/test/java/de/leonhard/storage/TomlTest.java b/src/test/java/de/leonhard/storage/TomlTest.java index 9b27bf21..8f8ee569 100644 --- a/src/test/java/de/leonhard/storage/TomlTest.java +++ b/src/test/java/de/leonhard/storage/TomlTest.java @@ -22,7 +22,7 @@ void setUp() { @Test void testGetDataType() { - Assertions.assertEquals(toml.getDataType(), DataType.SORTED); + Assertions.assertEquals(DataType.SORTED, toml.getDataType()); } @Test @@ -69,7 +69,7 @@ void testSet() { @AfterAll @Test - static void tearDown() { + void tearDown() { toml.clear(); Assertions.assertTrue(toml.getFile().delete()); } diff --git a/src/test/java/de/leonhard/storage/YamlTest.java b/src/test/java/de/leonhard/storage/YamlTest.java index 21df4997..b459c5cc 100644 --- a/src/test/java/de/leonhard/storage/YamlTest.java +++ b/src/test/java/de/leonhard/storage/YamlTest.java @@ -26,7 +26,7 @@ void setUp() { @Test void testGetDataType() { - Assertions.assertEquals(yaml.getDataType(), DataType.SORTED); + Assertions.assertEquals(DataType.SORTED, yaml.getDataType()); } @Test @@ -79,7 +79,7 @@ void testSet() { @AfterAll @Test - static void tearDown() { + void tearDown() { yaml.clear(); Assertions.assertTrue(yaml.getFile().delete()); }