public interface ConfigNode
| 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 |
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 getName()
Map<FiberId,ConfigAttribute<?>> getAttributes()
Attributes 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.
<R,A> Optional<R> getAttributeValue(FiberId id, ConfigType<R,A,?> type)
R - 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 existClassCastException - if the attribute exists but has a type that is not assignable to type<A> Optional<A> getAttributeValue(FiberId id, SerializableType<A> expectedType)
A - 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 existClassCastException - if the attribute exists but has a type that is not assignable to expectedType<A> ConfigAttribute<A> getOrCreateAttribute(FiberId id, SerializableType<A> attributeType, @Nullable A defaultValue)
A - 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 existgetAttributes()@Nullable ConfigBranch getParent()
null if it is not part of a config treevoid attachTo(ConfigBranch parent) throws DuplicateChildException, IllegalTreeStateException
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 detach().
parent - the new parent branch for this nodeDuplicateChildException - if the new parent already has a child of the same nameIllegalTreeStateException - if this node is already attached to another branchNodeCollection.add(ConfigNode, boolean)void detach()
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.
NodeCollection.remove(Object)