A - the type of aggregate valueE - the type of values held by <A>public final class ConfigAggregateBuilder<A,E> extends ConfigLeafBuilder<A>
ConfigLeafBuilder that produces aggregate ConfigLeafs.
Aggregate types are those that hold multiple values, such as List or arrays.
Settings with scalar types, such as Integer or String, are created using ConfigLeafBuilder.
constraintList, type| Modifier and Type | Method and Description |
|---|---|
AggregateConstraintsBuilder<A,E> |
beginConstraints()
Creates a constraint builder for this
ConfigLeafBuilder. |
static <E> ConfigAggregateBuilder<E[],E> |
create(ConfigTreeBuilder source,
java.lang.String name,
java.lang.Class<E[]> arrayType)
Creates and returns an
aggregate builder for an array type. |
static <S extends ConfigTreeBuilder,C extends java.util.Collection<E>,E> |
create(S source,
java.lang.String name,
java.lang.Class<? super C> collectionType,
java.lang.Class<E> componentType)
Creates and returns an
aggregate builder for a collection type. |
static boolean |
isAggregate(java.lang.Class<?> type)
Determines if a
Class object represents an aggregate type,
ie. |
ConfigAggregateBuilder<A,E> |
withComment(java.lang.String comment)
Sets the
ConfigLeaf's comment. |
ConfigAggregateBuilder<A,E> |
withDefaultValue(A defaultValue)
Sets the default value.
|
ConfigAggregateBuilder<A,E> |
withFinality()
Marks a setting as final.
|
ConfigAggregateBuilder<A,E> |
withFinality(boolean isFinal)
Sets the finality.
|
ConfigAggregateBuilder<A,E> |
withListener(java.util.function.BiConsumer<A,A> consumer)
Adds a listener to the
ConfigLeaf. |
ConfigAggregateBuilder<A,E> |
withName(java.lang.String name)
Sets the
ConfigLeaf's name. |
build, finishValue, finishValue, getTypepublic static boolean isAggregate(java.lang.Class<?> type)
Class object represents an aggregate type,
ie. if it is an Array or a Collection.type - the type to checktrue if type is an aggregate type;
false otherwisepublic static <E> ConfigAggregateBuilder<E[],E> create(ConfigTreeBuilder source, @Nonnull java.lang.String name, @Nonnull java.lang.Class<E[]> arrayType)
aggregate builder for an array type.E - the type of values held by arrayTypearrayType - the class of the array used for this aggregate builderisAggregate(java.lang.Class<?>)public static <S extends ConfigTreeBuilder,C extends java.util.Collection<E>,E> ConfigAggregateBuilder<C,E> create(S source, @Nonnull java.lang.String name, @Nonnull java.lang.Class<? super C> collectionType, @Nullable java.lang.Class<E> componentType)
aggregate builder for a collection type.C - the type collectionType represents. eg. ListE - the type componentType represents. eg. IntegercollectionType - the class of the collection used for this aggregate buildercomponentType - the class of the type of elements collectionType holdspublic ConfigAggregateBuilder<A,E> withName(java.lang.String name)
ConfigLeafBuilderConfigLeaf's name.
If null, or if this method is never called, the ConfigLeaf won't have a name. Thus, it might be ignored during (de)serialisation. It also won't be able to be found by name in its parent node.
withName in class ConfigLeafBuilder<A>name - the namethis builderConfigTree.lookup(java.lang.String)public ConfigAggregateBuilder<A,E> withComment(java.lang.String comment)
ConfigLeafBuilderConfigLeaf's comment.
If null, or if this method is never called, the ConfigLeaf won't have a comment. An empty comment (non null, but only consisting of whitespace) will be serialised.
withComment in class ConfigLeafBuilder<A>comment - the commentthis builderpublic ConfigAggregateBuilder<A,E> withListener(java.util.function.BiConsumer<A,A> consumer)
ConfigLeafBuilderConfigLeaf.
Listeners are called when the value of a ConfigLeaf is changed. They are of type BiConsumer: the first argument being the old value, and the second argument being the new value.
Listeners set with this method are chained: if there was already one specified, a new listener is created that calls the old one first, and then the new one.
withListener in class ConfigLeafBuilder<A>consumer - the listenerthis builderpublic ConfigAggregateBuilder<A,E> withDefaultValue(A defaultValue)
ConfigLeafBuilder If null, or if this method is never called, the ConfigLeaf will have no default value.
Note that every ConfigLeaf created from this builder will share a reference
to the given defaultValue. Immutability is encouraged.
withDefaultValue in class ConfigLeafBuilder<A>defaultValue - the default valuethis builderpublic ConfigAggregateBuilder<A,E> withFinality()
ConfigLeafBuilder As a result of this method, any attempt to update the value of the resulting setting will fail.
This method behaves as if: this.setFinal(true).
withFinality in class ConfigLeafBuilder<A>this builderConfigLeafBuilder.withFinality(boolean)public ConfigAggregateBuilder<A,E> withFinality(boolean isFinal)
ConfigLeafBuilder If true, the produced setting can not be changed.
It will be initialised with its default value, if there is one. Afterwards, it can not be changed again;
ConfigLeaf.setValue(Object) will always return false.
withFinality in class ConfigLeafBuilder<A>isFinal - whether or not the value can be changed after buildingthis builderpublic AggregateConstraintsBuilder<A,E> beginConstraints()
ConfigLeafBuilderConfigLeafBuilder.beginConstraints in class ConfigLeafBuilder<A>ConstraintsBuilder