Package com.amihaiemil.eoyaml
Class EmptyYamlSequence
- java.lang.Object
-
- com.amihaiemil.eoyaml.BaseYamlSequence
-
- com.amihaiemil.eoyaml.EmptyYamlSequence
-
- All Implemented Interfaces:
YamlNode
,YamlSequence
,Comparable<YamlNode>
,Iterable<YamlNode>
public class EmptyYamlSequence extends BaseYamlSequence
Representation of an empty YAML Sequence (or "[]"). A decorator aroundYamlSequence
with no values.- Since:
- 5.1.17
- Version:
- $Id: 6d7cc7d357394b494cbf3e56cb4cdd0a1513d852 $
- Author:
- Andrew Newman
-
-
Constructor Summary
Constructors Constructor Description EmptyYamlSequence(YamlSequence sequence)
Wrap an existing sequence - expects comments() to be implemented.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends YamlNode>
TasClass(Class<T> clazz, Node type)
Gives theYamlNode
instance from node class and node type.YamlMapping
asMapping()
Gives a Mapping value of the node.Scalar
asScalar()
Gives a String value of the node.YamlSequence
asSequence()
Gives a Sequence value of the node.YamlStream
asStream()
Gives a Stream value of the node.Comment
comment()
Comment referring to this Node.String
toString()
Print this YamlNode using a StringWriter to create its String representation.Collection<YamlNode>
values()
Fetch the values of this sequence.-
Methods inherited from class com.amihaiemil.eoyaml.BaseYamlSequence
compareTo, equals, hashCode, isEmpty, type
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface com.amihaiemil.eoyaml.YamlNode
asClass, asMapping, asScalar, asSequence, asStream
-
Methods inherited from interface com.amihaiemil.eoyaml.YamlSequence
date, dateTime, doubleNumber, floatNumber, foldedBlockScalar, integer, iterator, literalBlockScalar, longNumber, size, string, yamlMapping, yamlSequence
-
-
-
-
Constructor Detail
-
EmptyYamlSequence
public EmptyYamlSequence(YamlSequence sequence)
Wrap an existing sequence - expects comments() to be implemented.- Parameters:
sequence
- The sequence to wrap.
-
-
Method Detail
-
values
public final Collection<YamlNode> values()
Description copied from interface:YamlSequence
Fetch the values of this sequence.- Returns:
- Collection of
YamlNode
-
comment
public final Comment comment()
Description copied from interface:YamlNode
Comment referring to this Node.- Returns:
- Comment. If there is no comment, it will return an "empty" comment (an instance of Comment with empty-string value()).
-
asScalar
public final Scalar asScalar() throws YamlReadingException, ClassCastException
Description copied from interface:YamlNode
Gives a String value of the node.- Specified by:
asScalar
in interfaceYamlNode
- Returns:
- String value of the node.
- Throws:
YamlReadingException
- If the node type is not Scalar.ClassCastException
- If the node type couldn't defined correctly.
-
asMapping
public final YamlMapping asMapping() throws YamlReadingException, ClassCastException
Description copied from interface:YamlNode
Gives a Mapping value of the node.- Specified by:
asMapping
in interfaceYamlNode
- Returns:
- Mapping value of the node.
- Throws:
YamlReadingException
- If the node type is not Mapping.ClassCastException
- If the node type couldn't defined correctly.
-
asSequence
public final YamlSequence asSequence() throws YamlReadingException, ClassCastException
Description copied from interface:YamlNode
Gives a Sequence value of the node.- Specified by:
asSequence
in interfaceYamlNode
- Returns:
- Sequence value of the node.
- Throws:
YamlReadingException
- If the node type is not Sequence.ClassCastException
- If the node type couldn't defined correctly.
-
asStream
public final YamlStream asStream() throws YamlReadingException, ClassCastException
Description copied from interface:YamlNode
Gives a Stream value of the node.- Specified by:
asStream
in interfaceYamlNode
- Returns:
- Stream value of the node.
- Throws:
YamlReadingException
- If the node type is not Stream.ClassCastException
- If the node type couldn't defined correctly.
-
asClass
public final <T extends YamlNode> T asClass(Class<T> clazz, Node type) throws YamlReadingException, ClassCastException
Description copied from interface:YamlNode
Gives theYamlNode
instance from node class and node type.- Specified by:
asClass
in interfaceYamlNode
- Type Parameters:
T
- Requested aYamlNode
class instance.- Parameters:
clazz
- Requested aYamlNode
class.type
- Requested aNode
.- Returns:
- Requested a
YamlNode
. - Throws:
YamlReadingException
- If the type is not aYamlNode
.ClassCastException
- If the node type couldn't defined correctly.
-
toString
public final String toString()
Print this YamlNode using a StringWriter to create its String representation.- Overrides:
toString
in classObject
- Returns:
- String print of this YamlNode.
- Throws:
YamlPrintException
- If there is any I/O problem when printing the YAML.
-
-