Skip to content

Commit

Permalink
YAMLParser now supports YAML lists not parsed by the parser itself.
Browse files Browse the repository at this point in the history
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 _gui_ formatting in `FileUtils#formatStringToYaml(String)`.
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.
Updated README.md.
Updated FulmiCollection.
  • Loading branch information
fulminazzo committed Apr 4, 2024
1 parent 34d2701 commit 9a28973
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = 'it.fulminazzo'
version = '1.5.13'
version = '1.5.14'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,22 @@ default boolean isList(@NotNull String path) {
default <T> @Nullable List<T> getList(@NotNull String path, @NotNull Class<T> clazz) {
List<?> list = getObjectList(path);
if (list == null) return null;
return list.stream()
.map(o -> o == null ? null : clazz.isAssignableFrom(o.getClass()) ? clazz.cast(o) :
convertObjectToYAMLObject(path, o, clazz))
.filter(o -> check(path, o, clazz))
.collect(Collectors.toList());
List<T> actualList = new LinkedList<>();
for (int i = 0; i < list.size(); i++) {
Object o = list.get(i);
if (o == null) actualList.add(null);
else {
final T t;
if (clazz.isAssignableFrom(o.getClass())) t = clazz.cast(o);
else {
String p = path + "." + i;
t = convertObjectToYAMLObject(p, o, clazz);
check(p, t, clazz);
}
actualList.add(t);
}
}
return actualList;
}

/**
Expand Down

0 comments on commit 9a28973

Please sign in to comment.