T - The type of value this class holdspublic class ConfigValue<T> extends ConfigLeaf implements Property<T>
ConfigLeaf with some value of type T.ConfigLeaf| Constructor and Description |
|---|
ConfigValue(java.lang.String name,
java.lang.String comment,
T value,
T defaultValue,
java.util.function.BiConsumer<T,T> consumer,
java.util.List<Constraint<? super T>> constraintList,
java.lang.Class<T> type,
boolean isFinal)
Creates a
ConfigValue. |
| Modifier and Type | Method and Description |
|---|---|
static <C extends java.util.Collection<E>,E> |
builder(C defaultValue,
java.lang.Class<E> elementType)
Creates an aggregate
ConfigValueBuilder. |
static <T> ConfigValueBuilder.Scalar<T> |
builder(java.lang.Class<T> type)
Creates a scalar
ConfigValueBuilder. |
static <E> ConfigValueBuilder.Aggregate<E[],E> |
builder(E[] defaultValue)
Creates an aggregate
ConfigValueBuilder. |
static <T> ConfigValueBuilder.Scalar<T> |
builder(T defaultValue)
Creates a scalar
ConfigValueBuilder. |
java.util.List<Constraint<? super T>> |
getConstraints()
Returns the list of constraints for this item.
|
T |
getDefaultValue()
Returns the default value for this item.
|
java.util.function.BiConsumer<T,T> |
getListener()
Returns the listener for this item.
|
java.lang.Class<T> |
getType()
Returns the class of the type of the value being held
|
T |
getValue()
Returns the value being held
|
boolean |
setValue(T value)
Sets the value of this property.
|
getComment, getName, toStringpublic ConfigValue(@Nullable
java.lang.String name,
@Nullable
java.lang.String comment,
@Nullable
T value,
@Nullable
T defaultValue,
@Nonnull
java.util.function.BiConsumer<T,T> consumer,
@Nonnull
java.util.List<Constraint<? super T>> constraintList,
@Nonnull
java.lang.Class<T> type,
boolean isFinal)
ConfigValue.name - the name for this itemcomment - the comment for this itemvalue - the current valuedefaultValue - the default value for this item
consumer - the consumer or listener for this item. When this item's value changes, the consumer will be called with the old value as first argument and the new value as second argument.constraintList - the list of constraints for this item. For a value to be accepted, all constraints must be satisfied.type - the type of value this item holdsisFinal - whether or not this value can be change. If true, setValue(Object) will always return false, implying this was not mutated.@Nullable public T getValue()
HasValue@Nonnull public java.lang.Class<T> getType()
HasValuepublic boolean setValue(@Nullable
T value)
Property This can fail and return false if, for example, the value did not satisfy the constraints of the property.
@Nonnull public java.util.function.BiConsumer<T,T> getListener()
When this item's value changes, the consumer will be called with the old value as first argument and the new value as second argument.
@Nullable public T getDefaultValue()
@Nonnull public java.util.List<Constraint<? super T>> getConstraints()
For a call to setValue(T) to pass (and such, return true), the value must satisfy all constraints in this list.
public static <T> ConfigValueBuilder.Scalar<T> builder(@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 holdsScalarpublic static <T> ConfigValueBuilder.Scalar<T> builder(@Nonnull T defaultValue)
ConfigValueBuilder.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.Scalarpublic static <E> ConfigValueBuilder.Aggregate<E[],E> builder(@Nonnull E[] defaultValue)
ConfigValueBuilder.E - the type of elements defaultValue holdsdefaultValue - the default array of values the ConfigValue will hold.Aggregatepublic static <C extends java.util.Collection<E>,E> ConfigValueBuilder.Aggregate<C,E> builder(@Nonnull C defaultValue, 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 holds