public class YamlMappingImpl extends AbstractYamlNode implements MutableYamlMapping
UNNAMED_NODE
Modifier and Type | Method and Description |
---|---|
void |
addChild(String name,
YamlNode node)
Adds a new child node to the mapping with the provided name
|
YamlNode |
child(String name)
Gets a child node by its name
|
YamlMapping |
childAsMapping(String name)
Gets a child mapping node by its name
|
YamlScalar |
childAsScalar(String name)
Gets a child scalar node by its name
|
<T> T |
childAsScalarValue(String name)
Gets a child scalar node's value by its name
See
YamlScalar for the possible types
Please note that if the scalar's type is not the expected type T,
a ClassCastException is thrown at the call site. |
<T> T |
childAsScalarValue(String name,
Class<T> type)
Gets a child scalar node's value by its name with type hinting
See
YamlScalar for the possible types |
YamlSequence |
childAsSequence(String name)
Gets a child sequence node by its name
|
int |
childCount()
Returns the number of the children that the collection has
|
Iterable<YamlNode> |
children()
Returns the children nodes
|
Iterable<YamlNameNodePair> |
childrenPairs()
Returns the children as
YamlNameNodePair s
This method may have null values as the childNode
in the returned pairs if the node's values is explicitly defined
as !!null in the YAML document. |
void |
removeChild(String name)
Removes a child with the given name if exists
|
String |
toString() |
nodeName, parent, path, setNodeName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
setNodeName
public YamlNode child(String name)
YamlMapping
child
in interface YamlMapping
name
- the name of the child nodenull
otherwisepublic YamlMapping childAsMapping(String name)
YamlMapping
childAsMapping
in interface YamlMapping
name
- the name of the child nodenull
otherwisepublic YamlSequence childAsSequence(String name)
YamlMapping
childAsSequence
in interface YamlMapping
name
- the name of the child nodenull
otherwisepublic YamlScalar childAsScalar(String name)
YamlMapping
childAsScalar
in interface YamlMapping
name
- the name of the child nodenull
otherwisepublic <T> T childAsScalarValue(String name)
YamlMapping
YamlScalar
for the possible types
Please note that if the scalar's type is not the expected type T,
a ClassCastException
is thrown at the call site.childAsScalarValue
in interface YamlMapping
name
- the name of the child nodenull
otherwiseYamlScalar
,
YamlMapping.childAsScalarValue(String, Class)
public <T> T childAsScalarValue(String name, Class<T> type)
YamlMapping
YamlScalar
for the possible typeschildAsScalarValue
in interface YamlMapping
name
- the name of the child nodetype
- the type that the scalar's value type to be validated
againstYamlScalar
public Iterable<YamlNode> children()
YamlCollection
children
in interface YamlCollection
public Iterable<YamlNameNodePair> childrenPairs()
YamlMapping
YamlNameNodePair
s
This method may have null
values as the childNode
in the returned pairs if the node's values is explicitly defined
as !!null
in the YAML document.
The difference from the YamlCollection.children()
children method is
that YamlCollection.children()
does not return null
children
nodes, while YamlMapping.childrenPairs()
does.childrenPairs
in interface YamlMapping
Iterable
pair of node names and node instancespublic void addChild(String name, YamlNode node)
MutableYamlMapping
addChild
in interface MutableYamlMapping
name
- The name of the new childnode
- The child nodepublic void removeChild(String name)
MutableYamlMapping
removeChild
in interface MutableYamlMapping
name
- The name of the child to removepublic int childCount()
YamlCollection
childCount
in interface YamlCollection
Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.