public abstract class ConfigNodeImpl extends java.lang.Object implements ConfigNode, Commentable
ConfigNode,
ConfigBranchImpl,
ConfigLeafImpl| Constructor and Description |
|---|
ConfigNodeImpl(java.lang.String name,
java.lang.String comment)
Creates a new
ConfigLeaf. |
| Modifier and Type | Method and Description |
|---|---|
void |
attachTo(ConfigBranch parent)
Attaches this node to an existing branch.
|
void |
detach()
Detaches this node from its parent branch, if any.
|
java.util.Map<FiberId,ConfigAttribute<?>> |
getAttributes()
Returns the map describing the attributes of this node.
|
<A> java.util.Optional<A> |
getAttributeValue(FiberId id,
java.lang.Class<A> expectedType)
Retrieves the value of the attribute with the given id.
|
java.lang.String |
getComment()
Returns the comment that was assigned to this class
|
java.lang.String |
getName()
Returns this node's name.
|
<A> ConfigAttribute<A> |
getOrCreateAttribute(FiberId id,
java.lang.Class<A> attributeType,
A defaultValue)
Retrieves the attribute with the given id.
|
ConfigBranch |
getParent()
Returns this node's parent, if any.
|
java.lang.String |
toString() |
public ConfigNodeImpl(@Nonnull
java.lang.String name,
@Nullable
java.lang.String comment)
ConfigLeaf.name - the name for this leafcomment - the comment for this leaf@Nonnull public java.lang.String getName()
ConfigNodegetName in interface ConfigNode@Nullable public java.lang.String getComment()
CommentablegetComment in interface Commentable@Nullable public ConfigBranch getParent()
ConfigNodegetParent in interface ConfigNodenull if it is not part of a config treepublic java.util.Map<FiberId,ConfigAttribute<?>> getAttributes()
ConfigNodeAttributes store metadata pertaining to the node itself, rather than its value. The returned map can be mutated by third parties to supplement the default node metadata. Examples of attributes include translation keys or rendering information.
As the returned data structure is shared by every attribute source, attributes should be grouped by namespace.
getAttributes in interface ConfigNodepublic <A> ConfigAttribute<A> getOrCreateAttribute(FiberId id, java.lang.Class<A> attributeType, @Nullable A defaultValue)
ConfigNodegetOrCreateAttribute in interface ConfigNodeA - the type of value stored by the attributeid - the id of the desired attributeattributeType - the type of values held by the attributedefaultValue - the default value, used if the attribute does not existConfigNode.getAttributes()public <A> java.util.Optional<A> getAttributeValue(FiberId id, java.lang.Class<A> expectedType)
ConfigNodegetAttributeValue in interface ConfigNodeA - the type of values expected from the attributeid - the attribute's idexpectedType - the class object describing the type of values expectedOptional describing the value of the attribute,
or an empty Optional if the attribute does not existpublic void detach()
ConfigNode After this method has returned, this node will be removed from
the current parent's children, and this
node's parent will be set to null.
This method has no effect is this node has no parent.
detach in interface ConfigNodeNodeCollection.remove(Object)public void attachTo(ConfigBranch parent)
ConfigNode After this method has returned normally, this node will be part
of the branch's children, and this
node's parent will be set to parent.
If parent is null, this method does not mutate any state.
It will however still throw IllegalTreeStateException if this node
is not in a suitable state to be attached to another parent. To detach the node
from its current parent, use ConfigNode.detach().
attachTo in interface ConfigNodeparent - the new parent branch for this nodeNodeCollection.add(ConfigNode, boolean)public java.lang.String toString()
toString in class java.lang.Object