public final class ImmutableNode extends Object
An immutable default implementation for configuration nodes.
This class is used for an in-memory representation of hierarchical configuration data. It stores typical information like a node name, a value, child nodes, or attributes.
 After their creation, instances cannot be manipulated. There are methods for
 updating properties, but these methods return new ImmutableNode
 instances. Instances are created using the nested Builder class.
 
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
ImmutableNode.Builder
 A builder class for creating instances of  
ImmutableNode. | 
| Modifier and Type | Method and Description | 
|---|---|
ImmutableNode | 
addChild(ImmutableNode child)
Creates a new  
ImmutableNode instance which is a copy of this
 object, but has the given child node added. | 
Map<String,Object> | 
getAttributes()
Returns a map with the attributes of this node. 
 | 
List<ImmutableNode> | 
getChildren()
Returns a list with the children of this node. 
 | 
List<ImmutableNode> | 
getChildren(String name)
Returns a list with the children of this node. 
 | 
String | 
getNodeName()
Returns the name of this node. 
 | 
Object | 
getValue()
Returns the value of this node. 
 | 
ImmutableNode | 
removeAttribute(String name)
Returns a new  
ImmutableNode instance which is a copy of this
 object, but with the specified attribute removed. | 
ImmutableNode | 
removeChild(ImmutableNode child)
Returns a new  
ImmutableNode instance which is a copy of this
 object, but with the given child node removed. | 
ImmutableNode | 
replaceChild(ImmutableNode oldChild,
            ImmutableNode newChild)
Returns a new  
ImmutableNode instance which is a copy of this
 object, but with the given child replaced by the new one. | 
ImmutableNode | 
replaceChildren(Collection<ImmutableNode> newChildren)
Returns a new  
ImmutableNode instance which is a copy of this
 object, but with the children replaced by the ones in the passed in
 collection. | 
ImmutableNode | 
setAttribute(String name,
            Object value)
Returns a new  
ImmutableNode instance which is a copy of this
 object, but with the specified attribute set to the given value. | 
ImmutableNode | 
setAttributes(Map<String,?> newAttributes)
Returns a new  
ImmutableNode instance which is a copy of this
 object, but with all attributes added defined by the given map. | 
ImmutableNode | 
setName(String name)
Creates a new  
ImmutableNode instance which is a copy of this
 object with the name changed to the passed in value. | 
ImmutableNode | 
setValue(Object newValue)
Creates a new  
ImmutableNode instance which is a copy of this
 object with the value changed to the passed in value. | 
String | 
toString()  | 
public String getNodeName()
public Object getValue()
public List<ImmutableNode> getChildren()
public List<ImmutableNode> getChildren(String name)
name - the node name to findpublic Map<String,Object> getAttributes()
public ImmutableNode setName(String name)
ImmutableNode instance which is a copy of this
 object with the name changed to the passed in value.name - the name of the newly created nodepublic ImmutableNode setValue(Object newValue)
ImmutableNode instance which is a copy of this
 object with the value changed to the passed in value.newValue - the value of the newly created nodepublic ImmutableNode addChild(ImmutableNode child)
ImmutableNode instance which is a copy of this
 object, but has the given child node added.child - the child node to be added (must not be null)IllegalArgumentException - if the child node is nullpublic ImmutableNode removeChild(ImmutableNode child)
ImmutableNode instance which is a copy of this
 object, but with the given child node removed. If the child node does not
 belong to this node, the same node instance is returned.child - the child node to be removedpublic ImmutableNode replaceChild(ImmutableNode oldChild, ImmutableNode newChild)
ImmutableNode instance which is a copy of this
 object, but with the given child replaced by the new one. If the child to
 be replaced cannot be found, the same node instance is returned.oldChild - the child node to be replacednewChild - the replacing child node (must not be null)IllegalArgumentException - if the new child node is nullpublic ImmutableNode replaceChildren(Collection<ImmutableNode> newChildren)
ImmutableNode instance which is a copy of this
 object, but with the children replaced by the ones in the passed in
 collection. With this method all children can be replaced in a single
 step. For the collection the same rules apply as for
 ImmutableNode.Builder.addChildren(Collection).newChildren - the collection with the new children (may be
        null)public ImmutableNode setAttribute(String name, Object value)
ImmutableNode instance which is a copy of this
 object, but with the specified attribute set to the given value. If an
 attribute with this name does not exist, it is created now. Otherwise,
 the new value overrides the old one.name - the name of the attributevalue - the attribute valuepublic ImmutableNode setAttributes(Map<String,?> newAttributes)
ImmutableNode instance which is a copy of this
 object, but with all attributes added defined by the given map. This
 method is analogous to setAttribute(String, Object), but all
 attributes in the given map are added. If the map is null or
 empty, this method has no effect.newAttributes - the map with attributes to be addedpublic ImmutableNode removeAttribute(String name)
ImmutableNode instance which is a copy of this
 object, but with the specified attribute removed. If there is no
 attribute with the given name, the same node instance is returned.name - the name of the attributeCopyright © 2001–2020 The Apache Software Foundation. All rights reserved.