aboutsummaryrefslogtreecommitdiff
path: root/common/src/main/java/dev/isxander
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/main/java/dev/isxander')
-rw-r--r--common/src/main/java/dev/isxander/yacl3/api/ListOption.java5
-rw-r--r--common/src/main/java/dev/isxander/yacl3/impl/ListOptionImpl.java6
2 files changed, 8 insertions, 3 deletions
diff --git a/common/src/main/java/dev/isxander/yacl3/api/ListOption.java b/common/src/main/java/dev/isxander/yacl3/api/ListOption.java
index 0371c35..1f4adfa 100644
--- a/common/src/main/java/dev/isxander/yacl3/api/ListOption.java
+++ b/common/src/main/java/dev/isxander/yacl3/api/ListOption.java
@@ -76,6 +76,11 @@ public interface ListOption<T> extends OptionGroup, Option<List<T>> {
/**
* Sets the value that is used when creating new entries
*/
+ Builder<T> initial(@NotNull Supplier<T> initialValue);
+
+ /**
+ * Sets the value that is used when creating new entries
+ */
Builder<T> initial(@NotNull T initialValue);
Builder<T> controller(@NotNull Function<Option<T>, ControllerBuilder<T>> controller);
diff --git a/common/src/main/java/dev/isxander/yacl3/impl/ListOptionImpl.java b/common/src/main/java/dev/isxander/yacl3/impl/ListOptionImpl.java
index 25ff7ba..12842c1 100644
--- a/common/src/main/java/dev/isxander/yacl3/impl/ListOptionImpl.java
+++ b/common/src/main/java/dev/isxander/yacl3/impl/ListOptionImpl.java
@@ -21,7 +21,7 @@ public final class ListOptionImpl<T> implements ListOption<T> {
private final Component name;
private final OptionDescription description;
private final Binding<List<T>> binding;
- private final T initialValue;
+ private final Supplier<T> initialValue;
private final List<ListOptionEntry<T>> entries;
private final boolean collapsed;
private boolean available;
@@ -33,7 +33,7 @@ public final class ListOptionImpl<T> implements ListOption<T> {
private final List<BiConsumer<Option<List<T>>, List<T>>> listeners;
private final List<Runnable> refreshListeners;
- public ListOptionImpl(@NotNull Component name, @NotNull OptionDescription description, @NotNull Binding<List<T>> binding, @NotNull T initialValue, @NotNull Function<ListOptionEntry<T>, Controller<T>> controllerFunction, ImmutableSet<OptionFlag> flags, boolean collapsed, boolean available, int minimumNumberOfEntries, int maximumNumberOfEntries, boolean insertEntriesAtEnd, Collection<BiConsumer<Option<List<T>>, List<T>>> listeners) {
+ public ListOptionImpl(@NotNull Component name, @NotNull OptionDescription description, @NotNull Binding<List<T>> binding, @NotNull Supplier<T> initialValue, @NotNull Function<ListOptionEntry<T>, Controller<T>> controllerFunction, ImmutableSet<OptionFlag> flags, boolean collapsed, boolean available, int minimumNumberOfEntries, int maximumNumberOfEntries, boolean insertEntriesAtEnd, Collection<BiConsumer<Option<List<T>>, List<T>>> listeners) {
this.name = name;
this.description = description;
this.binding = binding;
@@ -105,7 +105,7 @@ public final class ListOptionImpl<T> implements ListOption<T> {
@Override
public ListOptionEntry<T> insertNewEntry() {
- ListOptionEntry<T> newEntry = entryFactory.create(initialValue);
+ ListOptionEntry<T> newEntry = entryFactory.create(initialValue.get());
if (insertEntriesAtEnd) {
entries.add(newEntry);
} else {