Allow rules to declare they only accept a set of options (#1560)

This commit is contained in:
altrisi authored and GitHub committed 2022-10-12 16:13:59 +02:00
1 parent b798d76d10
commit 635fb586c4
3 files changed
+20 -3

No files matched your search

@@ -85,6 +85,18 @@ public interface CarpetRule<T> {
*/
T defaultValue();
/**
* <p>Returns whether this rule is strict.</p>
*
* <p>A rule being strict means that it will only accept the suggestions returned by {@link #suggestions()} as valid values.</p>
*
* <p>Note that a rule implementation may return {@code false} in this method but still not accept options other than those
* returned in {@link #suggestions()}, only the opposite is guaranteed.</p>
*/
default boolean strict() {
return false;
}
/**
* <p>Sets this rule's value to the provided {@link String}, after first converting the {@link String} into a suitable type.</p>
*