Skip to content

Commit

Permalink
YamlInput.readYamlNode
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Apr 24, 2024
1 parent 45392bd commit 9a60a80
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/com/amihaiemil/eoyaml/YamlInput.java
Expand Up @@ -99,4 +99,20 @@ public interface YamlInput {
* @throws IOException if the input cannot be read for some reason
*/
Scalar readLiteralBlockScalar() throws IOException;

/**
* Read the given input as a generic YamlNode.
* @return YamlNode.
* @throws IOException If something goes wrong.
*/
default YamlNode readYamlNode() throws IOException {
final YamlNode document;
final YamlStream stream = this.readYamlStream();
if(stream.values().size() == 1) {
document = stream.iterator().next();
} else {
document = stream;
}
return document;
}
}

0 comments on commit 9a60a80

Please sign in to comment.