public abstract class ConfigNodeBuilder extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<FiberId,ConfigAttribute<?>> |
attributes |
protected String |
comment |
protected String |
name |
protected ConfigTree |
parent |
| Constructor and Description |
|---|
ConfigNodeBuilder(ConfigTree parent,
String name) |
| Modifier and Type | Method and Description |
|---|---|
abstract ConfigNode |
build()
Builds and returns a new
ConfigNode with the parent and name stored in this builder. |
ConfigNodeBuilder |
withAttribute(ConfigAttribute<?> attribute)
Adds a single
ConfigAttribute to the built ConfigNode. |
<A> ConfigNodeBuilder |
withAttribute(FiberId id,
SerializableType<A> type,
A defaultValue)
Adds a
ConfigAttribute to the built ConfigNode. |
ConfigNodeBuilder |
withAttributes(Collection<ConfigAttribute<?>> attributes)
Adds a collection of
ConfigAttribute to the built ConfigNode. |
ConfigNodeBuilder |
withComment(String comment)
Sets the
ConfigNode's comment. |
ConfigNodeBuilder |
withName(String name)
Sets the
ConfigNode's name. |
@Nullable protected ConfigTree parent
protected Map<FiberId,ConfigAttribute<?>> attributes
public ConfigNodeBuilder(@Nullable ConfigTree parent, @Nullable String name)
public ConfigNodeBuilder withName(String name)
ConfigNode's name.name - the namethis builderConfigTree.lookupLeaf(java.lang.String, io.github.fablabsmc.fablabs.api.fiber.v1.schema.type.SerializableType<T>)public ConfigNodeBuilder withComment(String comment)
ConfigNode's comment.
If null, or if this method is never called, the ConfigNode will not have a comment.
An empty comment (non null, but only consisting of whitespace) will be serialised.
comment - the commentthis builderpublic <A> ConfigNodeBuilder withAttribute(FiberId id, SerializableType<A> type, A defaultValue)
ConfigAttribute to the built ConfigNode.A - the type of values stored in the attributeid - the id of the attributetype - the class object representing the type of values stored in the attributedefaultValue - the attribute's default valuethis, for chainingConfigNode.getAttributes()public ConfigNodeBuilder withAttributes(Collection<ConfigAttribute<?>> attributes)
ConfigAttribute to the built ConfigNode.attributes - A collection of attributes.public ConfigNodeBuilder withAttribute(ConfigAttribute<?> attribute)
ConfigAttribute to the built ConfigNode.attribute - The attribute.public abstract ConfigNode build()
ConfigNode with the parent and name stored in this builder.