A - the type of aggregate valueE - the type of values held by <A>public final class ConfigAggregateBuilder<A,E> extends ConfigValueBuilder<A>
ConfigValueBuilder that produces aggregate ConfigValues.
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 ConfigValueBuilder.
constraintList, type| Modifier and Type | Method and Description |
|---|---|
AggregateConstraintsBuilder<ConfigAggregateBuilder<A,E>,A,E> |
constraints()
Creates a constraint builder for this
ConfigValueBuilder. |
static <C extends java.util.Collection<E>,E> |
create(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 <E> ConfigAggregateBuilder<E[],E> |
create(java.lang.String name,
java.lang.Class<E[]> arrayType)
Creates and returns an
aggregate builder for an array type. |
static boolean |
isAggregate(java.lang.Class<?> type)
Determines if a
Class object represents an aggregate type,
ie. |
ConfigAggregateBuilder<A,E> |
setFinal()
Marks a setting as final.
|
ConfigAggregateBuilder<A,E> |
setFinal(boolean isFinal)
Sets the finality.
|
ConfigAggregateBuilder<A,E> |
withComment(java.lang.String comment)
Sets the
ConfigValue's comment. |
ConfigAggregateBuilder<A,E> |
withDefaultValue(A defaultValue)
Sets the default value.
|
ConfigAggregateBuilder<A,E> |
withListener(java.util.function.BiConsumer<A,A> consumer)
Adds a listener to the
ConfigValue. |
ConfigAggregateBuilder<A,E> |
withName(java.lang.String name)
Sets the
ConfigValue's name. |
ConfigAggregateBuilder<A,E> |
withParent(Node node)
Sets the node that the
ConfigValue will be registered to. |
buildpublic 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(@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 <C extends java.util.Collection<E>,E> ConfigAggregateBuilder<C,E> create(@Nonnull java.lang.String name, @Nonnull java.lang.Class<? super C> collectionType, @Nonnull 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)
ConfigValueBuilderConfigValue's name.
If null, or if this method is never called, the ConfigValue 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 ConfigValueBuilder<A>name - the namethis builderNode.lookup(java.lang.String)public ConfigAggregateBuilder<A,E> withComment(java.lang.String comment)
ConfigValueBuilderConfigValue's comment.
If null, or if this method is never called, the ConfigValue won't have a comment. An empty comment (non null, but only consisting of whitespace) will be serialised.
withComment in class ConfigValueBuilder<A>comment - the commentthis builderpublic ConfigAggregateBuilder<A,E> withListener(java.util.function.BiConsumer<A,A> consumer)
ConfigValueBuilderConfigValue.
Listeners are called when the value of a ConfigValue 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 ConfigValueBuilder<A>consumer - the listenerthis builderpublic ConfigAggregateBuilder<A,E> withDefaultValue(A defaultValue)
ConfigValueBuilder If null, or if this method is never called, the ConfigValue will have no default value.
withDefaultValue in class ConfigValueBuilder<A>defaultValue - the default valuethis builderpublic ConfigAggregateBuilder<A,E> setFinal()
ConfigValueBuilder 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).
setFinal in class ConfigValueBuilder<A>this builderConfigValueBuilder.setFinal(boolean)public ConfigAggregateBuilder<A,E> setFinal(boolean isFinal)
ConfigValueBuilder 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.
setFinal in class ConfigValueBuilder<A>isFinal - the finalitythis builderpublic ConfigAggregateBuilder<A,E> withParent(Node node)
ConfigValueBuilderConfigValue will be registered to.withParent in class ConfigValueBuilder<A>node - The node the ConfigValue will be registered to.public AggregateConstraintsBuilder<ConfigAggregateBuilder<A,E>,A,E> constraints()
ConfigValueBuilderConfigValueBuilder.constraints in class ConfigValueBuilder<A>ConstraintsBuilder