From af472c8304c9e1864b5c2a1ab8472533fe8f5950 Mon Sep 17 00:00:00 2001 From: isXander Date: Sat, 12 Aug 2023 14:41:48 +0100 Subject: `ListOption.Builder#initial` overload to supply initial values based on context. (close #94) --- common/src/main/java/dev/isxander/yacl3/impl/ListOptionImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'common/src/main/java/dev/isxander/yacl3/impl') 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 implements ListOption { private final Component name; private final OptionDescription description; private final Binding> binding; - private final T initialValue; + private final Supplier initialValue; private final List> entries; private final boolean collapsed; private boolean available; @@ -33,7 +33,7 @@ public final class ListOptionImpl implements ListOption { private final List>, List>> listeners; private final List refreshListeners; - public ListOptionImpl(@NotNull Component name, @NotNull OptionDescription description, @NotNull Binding> binding, @NotNull T initialValue, @NotNull Function, Controller> controllerFunction, ImmutableSet flags, boolean collapsed, boolean available, int minimumNumberOfEntries, int maximumNumberOfEntries, boolean insertEntriesAtEnd, Collection>, List>> listeners) { + public ListOptionImpl(@NotNull Component name, @NotNull OptionDescription description, @NotNull Binding> binding, @NotNull Supplier initialValue, @NotNull Function, Controller> controllerFunction, ImmutableSet flags, boolean collapsed, boolean available, int minimumNumberOfEntries, int maximumNumberOfEntries, boolean insertEntriesAtEnd, Collection>, List>> listeners) { this.name = name; this.description = description; this.binding = binding; @@ -105,7 +105,7 @@ public final class ListOptionImpl implements ListOption { @Override public ListOptionEntry insertNewEntry() { - ListOptionEntry newEntry = entryFactory.create(initialValue); + ListOptionEntry newEntry = entryFactory.create(initialValue.get()); if (insertEntriesAtEnd) { entries.add(newEntry); } else { -- cgit