| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
name |
protected ConfigNodeBuilder |
parent |
| Constructor and Description |
|---|
ConfigNodeBuilder() |
| Modifier and Type | Method and Description |
|---|---|
ConfigNodeBuilder |
add(TreeItem item)
Attempts to introduce a new child to this node.
|
ConfigNodeBuilder |
add(TreeItem item,
boolean overwrite)
Attempts to introduce a new child to this node.
|
ConfigNodeBuilder |
applyFromPojo(java.lang.Object pojo)
Configure this builder using a POJO (Plain Old Java Object).
|
<C extends java.util.Collection<E>,E> |
beginAggregateValue(java.lang.String name,
C defaultValue,
java.lang.Class<E> elementType)
Creates an aggregate
ConfigValueBuilder. |
<E> ConfigAggregateBuilder<E[],E> |
beginAggregateValue(java.lang.String name,
E[] defaultValue)
Creates an aggregate
ConfigValueBuilder. |
<T> ConfigValueBuilder<T> |
beginValue(java.lang.String name,
java.lang.Class<T> type)
Creates a scalar
ConfigValueBuilder. |
<T> ConfigValueBuilder<T> |
beginValue(java.lang.String name,
T defaultValue)
Creates a
ConfigValueBuilder with the given default value. |
ConfigNode |
build()
Construct a new
ConfigNode based on this builder's specifications. |
ConfigNodeBuilder |
finishNode() |
ConfigNodeBuilder |
finishNode(java.util.function.Consumer<ConfigNode> action) |
ConfigNodeBuilder |
fork(java.lang.String name)
Forks this builder, creating a subtree whose parent is this node.
|
java.util.Collection<TreeItem> |
getItems()
Returns a collection of this node's children.
|
TreeItem |
lookup(java.lang.String name)
Tries to find a child in this node by name.
|
TreeItem |
remove(java.lang.String name)
Attempts to remove an item from this node by name.
|
ConfigNodeBuilder |
withComment(java.lang.String comment) |
ConfigNodeBuilder |
withName(java.lang.String name) |
ConfigNodeBuilder |
withParent(ConfigNodeBuilder parent) |
ConfigNodeBuilder |
withSeparateSerialization()
Marks the built node as being serialized separately
|
ConfigNodeBuilder |
withSeparateSerialization(boolean serializeSeparately) |
@Nullable protected ConfigNodeBuilder parent
@Nullable protected java.lang.String name
@Nonnull public java.util.Collection<TreeItem> getItems()
The returned collection is guaranteed to have no two nodes with the same name. Elements may be removed from it, but no elements may be added directly.
getItems in interface NodeLikeadd(TreeItem)@Nullable public TreeItem lookup(java.lang.String name)
public ConfigNodeBuilder withParent(ConfigNodeBuilder parent)
public ConfigNodeBuilder withName(java.lang.String name)
public ConfigNodeBuilder withComment(@Nullable java.lang.String comment)
public ConfigNodeBuilder withSeparateSerialization()
public ConfigNodeBuilder withSeparateSerialization(boolean serializeSeparately)
serializeSeparately - if true, the subtree will not appear in the
serialized representation of the built Nodethis, for chainingpublic ConfigNodeBuilder applyFromPojo(java.lang.Object pojo) throws FiberException
The node's structure will be based on the pojo's fields,
recursively generating settings. The generated settings can be configured
in the pojo's class declaration, using annotations such as Setting.
The generated ConfigValues will be bound to their respective fields,
setting the latter when the former's value is updated.
pojo - an object serving as a base to reflectively generate a config treethis, for chainingFiberExceptionSetting,
Settings,
AnnotatedSettings.applyToNode(ConfigNodeBuilder, Object)public <T> ConfigValueBuilder<T> beginValue(@Nonnull java.lang.String name, @Nonnull java.lang.Class<T> type)
ConfigValueBuilder.T - the type type representstype - the class of the type of value the ConfigValue produced by the builder holdsConfigValueBuilderpublic <T> ConfigValueBuilder<T> beginValue(@Nonnull java.lang.String name, @Nonnull T defaultValue)
ConfigValueBuilder with the given default value.T - the type of value the ConfigValue produced by the builder holdsdefaultValue - the default value of the ConfigValue that will be produced by the created builder.ConfigValueBuilder,
ConfigAggregateBuilderpublic <E> ConfigAggregateBuilder<E[],E> beginAggregateValue(@Nonnull java.lang.String name, @Nonnull E[] defaultValue)
ConfigValueBuilder.E - the type of elements defaultValue holdsdefaultValue - the default array of values the ConfigValue will hold.Aggregatepublic <C extends java.util.Collection<E>,E> ConfigAggregateBuilder<C,E> beginAggregateValue(@Nonnull java.lang.String name, @Nonnull C defaultValue, @Nullable java.lang.Class<E> elementType)
ConfigValueBuilder.C - the type of collection defaultValue isE - the type elementType representsdefaultValue - the default collection of values the ConfigValue will hold.elementType - the class of the type of elements defaultValue holdspublic ConfigNodeBuilder add(@Nonnull TreeItem item) throws FiberException
item - The child to addFiberException - if there was already a child by the same namePropertypublic ConfigNodeBuilder add(@Nonnull TreeItem item, boolean overwrite) throws FiberException
item - The child to addoverwrite - whether existing items should be overwrittenFiberException - if there was already a child by the same namePropertypublic TreeItem remove(java.lang.String name)
name - the name of the child that should be removednullpublic ConfigNodeBuilder fork(java.lang.String name)
name - the name of the new Nodepublic ConfigNode build()
ConfigNode based on this builder's specifications.
This method cannot be called more than once, as allowing multiple nodes to be built would result in duplicated references. To guard against this, usually undesirable, behaviour, this method will throw an exception on successive calls.
ConfigNodejava.lang.IllegalStateException - if this builder already built a nodepublic ConfigNodeBuilder finishNode()
public ConfigNodeBuilder finishNode(java.util.function.Consumer<ConfigNode> action)