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 `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.
Fixed YAMLException being thrown recursively.
Updated README.md.
Updated FulmiCollection.
  • Loading branch information
fulminazzo committed Apr 11, 2024
1 parent 16e7706 commit d0ff875
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1067,15 +1067,19 @@ default String getCurrentPath() {
* @param e the e
*/
default void throwException(String path, Object object, Throwable e) {
if (e.getCause() != null && (e instanceof RuntimeException || e instanceof InvocationTargetException))
e = e.getCause();
path = path == null ? "null" : path;
String currentPath = getCurrentPath();
if (currentPath != null && !currentPath.isEmpty()) path = currentPath + "." + path;
String message = e.getMessage();
if (e instanceof YAMLException) message = e.getMessage();
else message = e.getClass().getSimpleName() + " " + message;
throw new YAMLException(path, object, message);

if (e instanceof YAMLException) {
YAMLException yamlException = (YAMLException) e;
yamlException.setPath(path);
throw yamlException;
}

if (e.getCause() != null && (e instanceof RuntimeException || e instanceof InvocationTargetException))
e = e.getCause();
throw new YAMLException(path, object, e.getClass().getSimpleName() + " " + e.getMessage());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import it.fulminazzo.yamlparser.logging.LogMessage;
import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -10,8 +11,9 @@
* while working with IConfiguration instances.
*/
@Getter
@Setter
public class YAMLException extends RuntimeException {
private final @NotNull String path;
private @NotNull String path;
private final @NotNull String name;
private final @Nullable Object object;

Expand Down

0 comments on commit d0ff875

Please sign in to comment.