diff options
| author | Xander <xander@isxander.dev> | 2023-04-25 16:28:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-25 16:28:41 +0100 |
| commit | 13c7ba45ff201423eb8dba8a40cfb66ebb531439 (patch) | |
| tree | 1e799aa9da11fbc0833bc6b7c6e6799633c2ec50 /src/client/java/dev/isxander/yacl/impl | |
| parent | 8ba7196ae990fe9aa98680aba1b387e385fff99c (diff) | |
| download | YetAnotherConfigLib-13c7ba45ff201423eb8dba8a40cfb66ebb531439.tar.gz YetAnotherConfigLib-13c7ba45ff201423eb8dba8a40cfb66ebb531439.tar.bz2 YetAnotherConfigLib-13c7ba45ff201423eb8dba8a40cfb66ebb531439.zip | |
Architectury! (#61)
Diffstat (limited to 'src/client/java/dev/isxander/yacl/impl')
10 files changed, 0 insertions, 1685 deletions
diff --git a/src/client/java/dev/isxander/yacl/impl/ButtonOptionImpl.java b/src/client/java/dev/isxander/yacl/impl/ButtonOptionImpl.java deleted file mode 100644 index 33cb474..0000000 --- a/src/client/java/dev/isxander/yacl/impl/ButtonOptionImpl.java +++ /dev/null @@ -1,218 +0,0 @@ -package dev.isxander.yacl.impl; - -import com.google.common.collect.ImmutableSet; -import dev.isxander.yacl.api.*; -import dev.isxander.yacl.gui.YACLScreen; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; -import org.apache.commons.lang3.Validate; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Function; - -@ApiStatus.Internal -public final class ButtonOptionImpl implements ButtonOption { - private final Component name; - private final Component tooltip; - private final BiConsumer<YACLScreen, ButtonOption> action; - private boolean available; - private final Controller<BiConsumer<YACLScreen, ButtonOption>> controller; - private final Binding<BiConsumer<YACLScreen, ButtonOption>> binding; - - public ButtonOptionImpl( - @NotNull Component name, - @Nullable Component tooltip, - @NotNull BiConsumer<YACLScreen, ButtonOption> action, - boolean available, - @NotNull Function<ButtonOption, Controller<BiConsumer<YACLScreen, ButtonOption>>> controlGetter - ) { - this.name = name; - this.tooltip = tooltip; - this.action = action; - this.available = available; - this.controller = controlGetter.apply(this); - this.binding = new EmptyBinderImpl(); - } - - @Override - public @NotNull Component name() { - return name; - } - - @Override - public @NotNull Component tooltip() { - return tooltip; - } - - @Override - public BiConsumer<YACLScreen, ButtonOption> action() { - return action; - } - - @Override - public boolean available() { - return available; - } - - @Override - public void setAvailable(boolean available) { - this.available = available; - } - - @Override - public @NotNull Controller<BiConsumer<YACLScreen, ButtonOption>> controller() { - return controller; - } - - @Override - public @NotNull Binding<BiConsumer<YACLScreen, ButtonOption>> binding() { - return binding; - } - - @Override - public @NotNull Class<BiConsumer<YACLScreen, ButtonOption>> typeClass() { - throw new UnsupportedOperationException(); - } - - @Override - public @NotNull ImmutableSet<OptionFlag> flags() { - return ImmutableSet.of(); - } - - @Override - public boolean changed() { - return false; - } - - @Override - public @NotNull BiConsumer<YACLScreen, ButtonOption> pendingValue() { - throw new UnsupportedOperationException(); - } - - @Override - public void requestSet(BiConsumer<YACLScreen, ButtonOption> value) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean applyValue() { - return false; - } - - @Override - public void forgetPendingValue() { - - } - - @Override - public void requestSetDefault() { - - } - - @Override - public boolean isPendingValueDefault() { - throw new UnsupportedOperationException(); - } - - @Override - public void addListener(BiConsumer<Option<BiConsumer<YACLScreen, ButtonOption>>, BiConsumer<YACLScreen, ButtonOption>> changedListener) { - - } - - private static class EmptyBinderImpl implements Binding<BiConsumer<YACLScreen, ButtonOption>> { - @Override - public void setValue(BiConsumer<YACLScreen, ButtonOption> value) { - - } - - @Override - public BiConsumer<YACLScreen, ButtonOption> getValue() { - throw new UnsupportedOperationException(); - } - - @Override - public BiConsumer<YACLScreen, ButtonOption> defaultValue() { - throw new UnsupportedOperationException(); - } - } - - @ApiStatus.Internal - public static final class BuilderImpl implements ButtonOption.Builder { - private Component name; - private final List<Component> tooltipLines = new ArrayList<>(); - private boolean available = true; - private Function<ButtonOption, Controller<BiConsumer<YACLScreen, ButtonOption>>> controlGetter; - private BiConsumer<YACLScreen, ButtonOption> action; - - @Override - public ButtonOption.Builder name(@NotNull Component name) { - Validate.notNull(name, "`name` cannot be null"); - - this.name = name; - return this; - } - - @Override - public ButtonOption.Builder tooltip(@NotNull Component... tooltips) { - Validate.notNull(tooltips, "`tooltips` cannot be empty"); - - tooltipLines.addAll(List.of(tooltips)); - return this; - } - - @Override - public ButtonOption.Builder action(@NotNull BiConsumer<YACLScreen, ButtonOption> action) { - Validate.notNull(action, "`action` cannot be null"); - - this.action = action; - return this; - } - - @Override - @Deprecated - public ButtonOption.Builder action(@NotNull Consumer<YACLScreen> action) { - Validate.notNull(action, "`action` cannot be null"); - - this.action = (screen, button) -> action.accept(screen); - return this; - } - - @Override - public ButtonOption.Builder available(boolean available) { - this.available = available; - return this; - } - - @Override - public ButtonOption.Builder controller(@NotNull Function<ButtonOption, Controller<BiConsumer<YACLScreen, ButtonOption>>> control) { - Validate.notNull(control, "`control` cannot be null"); - - this.controlGetter = control; - return this; - } - - @Override - public ButtonOption build() { - Validate.notNull(name, "`name` must not be null when building `Option`"); - Validate.notNull(controlGetter, "`control` must not be null when building `Option`"); - Validate.notNull(action, "`action` must not be null when building `Option`"); - - MutableComponent concatenatedTooltip = Component.empty(); - boolean first = true; - for (Component line : tooltipLines) { - if (!first) concatenatedTooltip.append("\n"); - first = false; - - concatenatedTooltip.append(line); - } - - return new ButtonOptionImpl(name, concatenatedTooltip, action, available, controlGetter); - } - } -} diff --git a/src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java b/src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java deleted file mode 100644 index 2d39eb9..0000000 --- a/src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java +++ /dev/null @@ -1,137 +0,0 @@ -package dev.isxander.yacl.impl; - -import com.google.common.collect.ImmutableList; -import dev.isxander.yacl.api.ConfigCategory; -import dev.isxander.yacl.api.ListOption; -import dev.isxander.yacl.api.Option; -import dev.isxander.yacl.api.OptionGroup; -import dev.isxander.yacl.impl.utils.YACLConstants; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.ComponentContents; -import net.minecraft.network.chat.MutableComponent; -import org.apache.commons.lang3.Validate; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -@ApiStatus.Internal -public final class ConfigCategoryImpl implements ConfigCategory { - private final Component name; - private final ImmutableList<OptionGroup> groups; - private final Component tooltip; - - public ConfigCategoryImpl(Component name, ImmutableList<OptionGroup> groups, Component tooltip) { - this.name = name; - this.groups = groups; - this.tooltip = tooltip; - } - - @Override - public @NotNull Component name() { - return name; - } - - @Override - public @NotNull ImmutableList<OptionGroup> groups() { - return groups; - } - - @Override - public @NotNull Component tooltip() { - return tooltip; - } - - @ApiStatus.Internal - public static final class BuilderImpl implements Builder { - private Component name; - - private final List<Option<?>> rootOptions = new ArrayList<>(); - private final List<OptionGroup> groups = new ArrayList<>(); - - private final List<Component> tooltipLines = new ArrayList<>(); - - @Override - public Builder name(@NotNull Component name) { - Validate.notNull(name, "`name` cannot be null"); - - this.name = name; - return this; - } - - @Override - public Builder option(@NotNull Option<?> option) { - Validate.notNull(option, "`option` must not be null"); - - if (option instanceof ListOption<?> listOption) { - YACLConstants.LOGGER.warn("Adding list option as an option is not supported! Rerouting to group!"); - return group(listOption); - } - - this.rootOptions.add(option); - return this; - } - - @Override - public Builder options(@NotNull Collection<? extends Option<?>> options) { - Validate.notNull(options, "`options` must not be null"); - - if (options.stream().anyMatch(ListOption.class::isInstance)) - throw new UnsupportedOperationException("List options must not be added as an option but a group!"); - - this.rootOptions.addAll(options); - return this; - } - - @Override - public Builder group(@NotNull OptionGroup group) { - Validate.notNull(group, "`group` must not be null"); - - this.groups.add(group); - return this; - } - - @Override - public Builder groups(@NotNull Collection<OptionGroup> groups) { - Validate.notEmpty(groups, "`groups` must not be empty"); - - this.groups.addAll(groups); - return this; - } - - @Override - public Builder tooltip(@NotNull Component... tooltips) { - Validate.notEmpty(tooltips, "`tooltips` cannot be empty"); - - tooltipLines.addAll(List.of(tooltips)); - return this; - } - - @Override - public ConfigCategory build() { - Validate.notNull(name, "`name` must not be null to build `ConfigCategory`"); - - List<OptionGroup> combinedGroups = new ArrayList<>(); - combinedGroups.add(new OptionGroupImpl(Component.empty(), Component.empty(), ImmutableList.copyOf(rootOptions), false, true)); - combinedGroups.addAll(groups); - - Validate.notEmpty(combinedGroups, "at least one option must be added to build `ConfigCategory`"); - - MutableComponent concatenatedTooltip = Component.empty(); - boolean first = true; - for (Component line : tooltipLines) { - if (line.getContents() == ComponentContents.EMPTY) - continue; - - if (!first) concatenatedTooltip.append("\n"); - first = false; - - concatenatedTooltip.append(line); - } - - return new ConfigCategoryImpl(name, ImmutableList.copyOf(combinedGroups), concatenatedTooltip); - } - } -} diff --git a/src/client/java/dev/isxander/yacl/impl/GenericBindingImpl.java b/src/client/java/dev/isxander/yacl/impl/GenericBindingImpl.java deleted file mode 100644 index 0d668c6..0000000 --- a/src/client/java/dev/isxander/yacl/impl/GenericBindingImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package dev.isxander.yacl.impl; - -import dev.isxander.yacl.api.Binding; - -import java.util.function.Consumer; -import java.util.function.Supplier; - -public final class GenericBindingImpl<T> implements Binding<T> { - private final T def; - private final Supplier<T> getter; - private final Consumer<T> setter; - - public GenericBindingImpl(T def, Supplier<T> getter, Consumer<T> setting) { - this.def = def; - this.getter = getter; - this.setter = setting; - } - - - @Override - public void setValue(T value) { - setter.accept(value); - } - - @Override - public T getValue() { - return getter.get(); - } - - @Override - public T defaultValue() { - return def; - } - -} diff --git a/src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java b/src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java deleted file mode 100644 index b6c3c09..0000000 --- a/src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -package dev.isxander.yacl.impl; - -import com.google.common.collect.ImmutableSet; -import dev.isxander.yacl.api.*; -import dev.isxander.yacl.gui.controllers.LabelController; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; -import org.apache.commons.lang3.Validate; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.function.BiConsumer; - -@ApiStatus.Internal -public final class LabelOptionImpl implements LabelOption { - private final Component label; - private final Component name = Component.literal("Label Option"); - private final Component tooltip = Component.empty(); - private final LabelController labelController; - private final Binding<Component> binding; - - public LabelOptionImpl(Component label) { - this.label = label; - this.labelController = new LabelController(this); - this.binding = Binding.immutable(label); - } - - @Override - public @NotNull Component label() { - return label; - } - - @Override - public @NotNull Component name() { - return name; - } - - @Override - public @NotNull Component tooltip() { - return tooltip; - } - - @Override - public @NotNull Controller<Component> controller() { - return labelController; - } - - @Override - public @NotNull Binding<Component> binding() { - return binding; - } - - @Override - public boolean available() { - return true; - } - - @Override - public void setAvailable(boolean available) { - throw new UnsupportedOperationException("Label options cannot be disabled."); - } - - @Override - public @NotNull Class<Component> typeClass() { - return Component.class; - } - - @Override - public @NotNull ImmutableSet<OptionFlag> flags() { - return ImmutableSet.of(); - } - - @Override - public boolean changed() { - return false; - } - - @Override - public @NotNull Component pendingValue() { - return label; - } - - @Override - public void requestSet(Component value) { - - } - - @Override - public boolean applyValue() { - return false; - } - - @Override - public void forgetPendingValue() { - - } - - @Override - public void requestSetDefault() { - - } - - @Override - public boolean isPendingValueDefault() { - return true; - } - - @Override - public boolean canResetToDefault() { - return false; - } - - @Override - public void addListener(BiConsumer<Option<Component>, Component> changedListener) { - - } - - @ApiStatus.Internal - public static final class BuilderImpl implements LabelOption.Builder { - private final List<Component> lines = new ArrayList<>(); - - @Override - public dev.isxander.yacl.api.LabelOption.Builder line(@NotNull Component line) { - Validate.notNull(line, "`line` must not be null"); - - this.lines.add(line); - return this; - } - - @Override - public dev.isxander.yacl.api.LabelOption.Builder lines(@NotNull Collection<? extends Component> lines) { - this.lines.addAll(lines); - return this; - } - - @Override - public LabelOption build() { - MutableComponent text = Component.empty(); - Iterator<Component> iterator = lines.iterator(); - while (iterator.hasNext()) { - text.append(iterator.next()); - - if (iterator.hasNext()) - text.append("\n"); - } - - return new LabelOptionImpl(text); - } - } -} diff --git a/src/client/java/dev/isxander/yacl/impl/ListOptionEntryImpl.java b/src/client/java/dev/isxander/yacl/impl/ListOptionEntryImpl.java deleted file mode 100644 index c15efe6..0000000 --- a/src/client/java/dev/isxander/yacl/impl/ListOptionEntryImpl.java +++ /dev/null @@ -1,149 +0,0 @@ -package dev.isxander.yacl.impl; - -import dev.isxander.yacl.api.*; -import dev.isxander.yacl.api.utils.Dimension; -import dev.isxander.yacl.gui.AbstractWidget; -import dev.isxander.yacl.gui.YACLScreen; -import dev.isxander.yacl.gui.controllers.ListEntryWidget; -import net.minecraft.network.chat.Component; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiConsumer; -import java.util.function.Function; - -@ApiStatus.Internal -public final class ListOptionEntryImpl<T> implements ListOptionEntry<T> { - private final ListOptionImpl<T> group; - - private T value; - - private final Binding<T> binding; - private final Controller<T> controller; - - ListOptionEntryImpl(ListOptionImpl<T> group, T initialValue, @NotNull Function<ListOptionEntry<T>, Controller<T>> controlGetter) { - this.group = group; - this.value = initialValue; - this.binding = new EntryBinding(); - this.controller = new EntryController<>(controlGetter.apply(this), this); - } - - @Override - public @NotNull Component name() { - return Component.empty(); - } - - @Override - public @NotNull Component tooltip() { - return Component.empty(); - } - - @Override - public @NotNull Controller<T> controller() { - return controller; - } - - @Override - public @NotNull Binding<T> binding() { - return binding; - } - - @Override - public boolean available() { - return parentGroup().available(); - } - - @Override - public void setAvailable(boolean available) { - - } - - @Override - public ListOption<T> parentGroup() { - return group; - } - - @Override - public boolean changed() { - return false; - } - - @Override - public @NotNull T pendingValue() { - return value; - } - - @Override - public void requestSet(T value) { - binding.setValue(value); - } - - @Override - public boolean applyValue() { - return false; - } - - @Override - public void forgetPendingValue() { - - } - - @Override - public void requestSetDefault() { - - } - - @Override - public boolean isPendingValueDefault() { - return false; - } - - @Override - public boolean canResetToDefault() { - return false; - } - - @Override - public void addListener(BiConsumer<Option<T>, T> changedListener) { - - } - - /** - * Open in case mods need to find the real controller type. - */ - @ApiStatus.Internal - public record EntryController<T>(Controller<T> controller, ListOptionEntryImpl<T> entry) implements Controller<T> { - @Override - public Option<T> option() { - return controller.option(); - } - - @Override - public Component formatValue() { - return controller.formatValue(); - } - - @Override - public AbstractWidget provideWidget(YACLScreen screen, Dimension<Integer> widgetDimension) { - return new ListEntryWidget(screen, entry, controller.provideWidget(screen, widgetDimension)); - } - } - - private class EntryBinding implements Binding<T> { - @Override - public void setValue(T newValue) { - value = newValue; - group.callListeners(); - } - - @Override - public T getValue() { - return value; - } - - @Override - public T defaultValue() { - throw new UnsupportedOperationException(); - } - } -} diff --git a/src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java b/src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java deleted file mode 100644 index 27e90ad..0000000 --- a/src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java +++ /dev/null @@ -1,338 +0,0 @@ -package dev.isxander.yacl.impl; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import dev.isxander.yacl.api.*; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; -import org.apache.commons.lang3.Validate; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.*; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -@ApiStatus.Internal -public final class ListOptionImpl<T> implements ListOption<T> { - private final Component name; - private final Component tooltip; - private final Binding<List<T>> binding; - private final T initialValue; - private final List<ListOptionEntry<T>> entries; - private final boolean collapsed; - private boolean available; - private final Class<T> typeClass; - private final ImmutableSet<OptionFlag> flags; - private final EntryFactory entryFactory; - private final List<BiConsumer<Option<List<T>>, List<T>>> listeners; - private final List<Runnable> refreshListeners; - - public ListOptionImpl(@NotNull Component name, @NotNull Component tooltip, @NotNull Binding<List<T>> binding, @NotNull T initialValue, @NotNull Class<T> typeClass, @NotNull Function<ListOptionEntry<T>, Controller<T>> controllerFunction, ImmutableSet<OptionFlag> flags, boolean collapsed, boolean available, Collection<BiConsumer<Option<List<T>>, List<T>>> listeners) { - this.name = name; - this.tooltip = tooltip; - this.binding = binding; - this.initialValue = initialValue; - this.entryFactory = new EntryFactory(controllerFunction); - this.entries = createEntries(binding().getValue()); - this.collapsed = collapsed; - this.typeClass = typeClass; - this.flags = flags; - this.available = available; - this.listeners = new ArrayList<>(); - this.listeners.addAll(listeners); - this.refreshListeners = new ArrayList<>(); - callListeners(); - } - - @Override - public @NotNull Component name() { - return this.name; - } - - @Override - public @NotNull Component tooltip() { - return this.tooltip; - } - - @Override - public @NotNull ImmutableList<ListOptionEntry<T>> options() { - return ImmutableList.copyOf(entries); - } - - @Override - public @NotNull Controller<List<T>> controller() { - throw new UnsupportedOperationException(); - } - - @Override - public @NotNull Binding<List<T>> binding() { - return binding; - } - - @Override - public @NotNull Class<List<T>> typeClass() { - throw new UnsupportedOperationException(); - } - - @Override - public @NotNull Class<T> elementTypeClass() { - return typeClass; - } - - @Override - public boolean collapsed() { - return collapsed; - } - - @Override - public @NotNull ImmutableSet<OptionFlag> flags() { - return flags; - } - - @Override - public @NotNull ImmutableList<T> pendingValue() { - return ImmutableList.copyOf(entries.stream().map(Option::pendingValue).toList()); - } - - @Override - public void insertEntry(int index, ListOptionEntry<?> entry) { - entries.add(index, (ListOptionEntry<T>) entry); - onRefresh(); - } - - @Override - public ListOptionEntry<T> insertNewEntryToTop() { - ListOptionEntry<T> newEntry = entryFactory.create(initialValue); - entries.add(0, newEntry); - onRefresh(); - return newEntry; - } - - @Override - public void removeEntry(ListOptionEntry<?> entry) { - if (entries.remove(entry)) - onRefresh(); - } - - @Override - public int indexOf(ListOptionEntry<?> entry) { - return entries.indexOf(entry); - } - - @Override - public void requestSet(List<T> value) { - entries.clear(); - entries.addAll(createEntries(value)); - onRefresh(); - } - - @Override - public boolean changed() { - return !binding().getValue().equals(pendingValue()); - } - - @Override - public boolean applyValue() { - if (changed()) { - binding().setValue(pendingValue()); - return true; - } - return false; - } - - @Override - public void forgetPendingValue() { - requestSet(binding().getValue()); - } - - @Override - public void requestSetDefault() { - requestSet(binding().defaultValue()); - } - - @Override - public boolean isPendingValueDefault() { - return binding().defaultValue().equals(pendingValue()); - } - - @Override - public boolean available() { - return available; - } - - @Override - public void setAvailable(boolean available) { - this.available = available; - } - - @Override - public void addListener(BiConsumer<Option<List<T>>, List<T>> changedListener) { - this.listeners.add(changedListener); - } - - @Override - public void addRefreshListener(Runnable changedListener) { - this.refreshListeners.add(changedListener); - } - - @Override - public boolean isRoot() { - return false; - } - - private List<ListOptionEntry<T>> createEntries(Collection<T> values) { - return values.stream().map(entryFactory::create).collect(Collectors.toList()); - } - - void callListeners() { - List<T> pendingValue = pendingValue(); - this.listeners.forEach(listener -> listener.accept(this, pendingValue)); - } - - private void onRefresh() { - refreshListeners.forEach(Runnable::run); - callListeners(); - } - - private class EntryFactory { - private final Function<ListOptionEntry<T>, Controller<T>> controllerFunction; - - private EntryFactory(Function<ListOptionEntry<T>, Controller<T>> controllerFunction) { - this.controllerFunction = controllerFunction; - } - - public ListOptionEntry<T> create(T initialValue) { - return new ListOptionEntryImpl<>(ListOptionImpl.this, initialValue, controllerFunction); - } - } - - @ApiStatus.Internal - public static final class BuilderImpl<T> implements ListOption.Builder<T> { - private Component name = Component.empty(); - private final List<Component> tooltipLines = new ArrayList<>(); - private Function<ListOptionEntry<T>, Controller<T>> controllerFunction; - private Binding<List<T>> binding = null; - private final Set<OptionFlag> flags = new HashSet<>(); - private T initialValue; - private boolean collapsed = false; - private boolean available = true; - private final List<BiConsumer<Option<List<T>>, List<T>>> listeners = new ArrayList<>(); - private final Class<T> typeClass; - - public BuilderImpl(Class<T> typeClass) { - this.typeClass = typeClass; - } - - @Override - public ListOption.Builder<T> name(@NotNull Component name) { - Validate.notNull(name, "`name` must not be null"); - - this.name = name; - return this; - } - - @Override - public ListOption.Builder<T> tooltip(@NotNull Component... tooltips) { - Validate.notEmpty(tooltips, "`tooltips` cannot be empty"); - - tooltipLines.addAll(List.of(tooltips)); - return this; - } - - @Override - public ListOption.Builder<T> initial(@NotNull T initialValue) { - Validate.notNull(initialValue, "`initialValue` cannot be empty"); - - this.initialValue = initialValue; - return this; - } - - @Override - public ListOption.Builder<T> controller(@NotNull Function<ListOptionEntry<T>, Controller<T>> control) { - Validate.notNull(control |
