From b8fb36b0f162e7de62628ab1f9ea6ddaa5b952d9 Mon Sep 17 00:00:00 2001 From: Fulminazzo Date: Tue, 9 Apr 2024 13:11:27 +0200 Subject: [PATCH] YAMLParser now supports YAML lists not parsed by the parser itself. This means that list of type ```yaml list: - test: "Hello" - test: "Hi" ``` will be parsed as a list of (ConfigurationSection)[src/main/java/it/fulminazzo/yamlparser/configuration/ConfigurationSection]. Totally reworked classes separation to respect packaging conventions. Reworked FileConfiguration#addParsers method. Reworked `FileConfiguration#newYaml` method to support older versions of SnakeYAML. Renamed `it.fulminazzo.yamlparser.configurations` package to `it.fulminazzo.yamlparser.configuration`. Made FileConfiguration and ConfigurationSection final. Added support for escaped dot characters: now it will be able to use `\.` in paths to allow for dotted strings to be parsed. Added support for BigDecimal notation when getting Number types. Added `unquote` method to remove quoted strings when saving or loading. Added `getOptional` method in IConfiguration. Added `getOptionalList` method in IConfiguration. Added _gui_ formatting in `FileUtils#formatStringToYaml(String)`. Added `IConfiguration#setList` to save lists in dash form. Now IConfiguration extends Serializable. Removed nullity annotations from **YAMLParser** methods. Fixed dotted test error. Fixed `IConfiguration#getKeys` not returning an ordered set. Fixed NullPointerException in `IConfiguration#throwException` method. Fixed MapYAMLParser not supporting primitive types. Fixed `FileConfiguration#getParser` method to look first for equal object classes. Fixed `CollectionYAMLParser` not returning null values in non-specified indexes. Fixed `IConfiguration#getList(String, Class)` not checking correct paths. Fixed `IConfiguration#contains` not checking for valid section. Fixed `EnumYAMLParser` not making name uppercase. Fixed `CollectionYAMLParser` not returning null in case of invalid object. Updated README.md. Updated FulmiCollection. --- .../fulminazzo/yamlparser/parsers/CollectionYAMLParser.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/fulminazzo/yamlparser/parsers/CollectionYAMLParser.java b/src/main/java/it/fulminazzo/yamlparser/parsers/CollectionYAMLParser.java index c19ceac..46e4bc5 100644 --- a/src/main/java/it/fulminazzo/yamlparser/parsers/CollectionYAMLParser.java +++ b/src/main/java/it/fulminazzo/yamlparser/parsers/CollectionYAMLParser.java @@ -31,6 +31,8 @@ public CollectionYAMLParser(Class aClass) { @Override protected BiFunctionException getLoader() { return (c, s) -> { + System.out.println(c); + System.out.println(s); if (c.isConfigurationSection(s)) { @Nullable Map map = mapYamlParser.load(c, s); if (map == null) return null; @@ -43,8 +45,8 @@ protected BiFunctionException getLoader() { return (C) result; } else { Object o = c.getObject(s); - if (o == null || !getOClass().isAssignableFrom(o.getClass())) return null; - return (C) o; + if (o instanceof Collection) return (C) o; + else return null; } }; }