public abstract class ConfigNodeImpl extends Object implements ConfigNode, Commentable
ConfigNode,
ConfigBranchImpl,
ConfigLeafImpl| Constructor and Description |
|---|
ConfigNodeImpl(String name,
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.
|
Map<FiberId,ConfigAttribute<?>> |
getAttributes()
Returns the map describing the attributes of this node.
|
<R,A> Optional<R> |
getAttributeValue(FiberId id,
ConfigType<R,A,?> type)
Retrieves the value of the attribute with the given id and converts it to a runtime type.
|
<A> Optional<A> |
getAttributeValue(FiberId id,
SerializableType<A> expectedType)
Retrieves the value of the attribute with the given id.
|
String |
getComment()
Returns the comment that was assigned to this class.
|
String |
getName()
Returns this node's name.
|
<A> ConfigAttribute<A> |
getOrCreateAttribute(FiberId id,
SerializableType<A> attributeType,
A defaultValue)
Retrieves the attribute with the given id.
|
ConfigBranch |
getParent()
Returns this node's parent, if any.
|
String |
toString() |
@Nonnull public String getName()
ConfigNodegetName in interface ConfigNode@Nullable public String getComment()
CommentablegetComment in interface Commentable@Nullable public ConfigBranch getParent()
ConfigNodegetParent in interface ConfigNodenull if it is not part of a config treepublic 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, SerializableType<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> Optional<A> getAttributeValue(FiberId id, SerializableType<A> expectedType)
ConfigNodegetAttributeValue in interface ConfigNodeA - the type of values expected from the attributeid - the attribute's idexpectedType - a SerializableType describing the type of values expectedOptional describing the value of the attribute,
or an empty Optional if the attribute does not existpublic <R,A> Optional<R> getAttributeValue(FiberId id, ConfigType<R,A,?> type)
ConfigNodegetAttributeValue in interface ConfigNodeR - the runtime type to which the attribute value will be convertedA - the type of values expected from the attributeid - the attribute's idtype - a ConfigType describing the type of values expected and
how to convert them to the desired runtime typeOptional describing the value of the attribute,
or an empty Optional if the attribute does not existpublic void detach()
ConfigNodeAfter 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)
ConfigNodeAfter 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)