diff options
author | Xander <xander@isxander.dev> | 2022-12-11 19:31:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-11 19:31:56 +0000 |
commit | dd65110f60aa3e32c2970863a06a7682520cce5e (patch) | |
tree | 44612c6aa85374efa639462592ae706fb93f2575 /src/client/java/dev/isxander/yacl/api/OptionGroup.java | |
parent | b890c2f0eec3627e552f1c6cfc846c8a55663243 (diff) | |
download | YetAnotherConfigLib-dd65110f60aa3e32c2970863a06a7682520cce5e.tar.gz YetAnotherConfigLib-dd65110f60aa3e32c2970863a06a7682520cce5e.tar.bz2 YetAnotherConfigLib-dd65110f60aa3e32c2970863a06a7682520cce5e.zip |
[Feature] Lists (#40)
Diffstat (limited to 'src/client/java/dev/isxander/yacl/api/OptionGroup.java')
-rw-r--r-- | src/client/java/dev/isxander/yacl/api/OptionGroup.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/client/java/dev/isxander/yacl/api/OptionGroup.java b/src/client/java/dev/isxander/yacl/api/OptionGroup.java index 3364bdf..6cc6c7f 100644 --- a/src/client/java/dev/isxander/yacl/api/OptionGroup.java +++ b/src/client/java/dev/isxander/yacl/api/OptionGroup.java @@ -31,7 +31,7 @@ public interface OptionGroup { /** * List of all options in the group */ - @NotNull ImmutableList<Option<?>> options(); + @NotNull ImmutableList<? extends Option<?>> options(); /** * Dictates if the group should be collapsed by default. @@ -96,6 +96,9 @@ public interface OptionGroup { public Builder option(@NotNull Option<?> option) { Validate.notNull(option, "`option` must not be null"); + if (option instanceof ListOption<?>) + throw new UnsupportedOperationException("List options must not be added as an option but a group!"); + this.options.add(option); return this; } @@ -109,6 +112,9 @@ public interface OptionGroup { public Builder options(@NotNull Collection<? extends Option<?>> options) { Validate.notEmpty(options, "`options` must not be empty"); + if (options.stream().anyMatch(ListOption.class::isInstance)) + throw new UnsupportedOperationException("List options must not be added as an option but a group!"); + this.options.addAll(options); return this; } |