File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
commands/src/main/java/com/wizardlybump17/wlib/command/input Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 33import org .jetbrains .annotations .NotNull ;
44import org .jetbrains .annotations .Nullable ;
55
6+ import java .util .List ;
67import java .util .Objects ;
78
89public interface AllowedInputs <T > {
@@ -19,6 +20,10 @@ public interface AllowedInputs<T> {
1920 return (Any <T >) Any .NOT_NULL ;
2021 }
2122
23+ static <T > AllowedListInputs .@ NotNull Values <T > values (@ NotNull List <T > values ) {
24+ return new AllowedListInputs .Values <>(values );
25+ }
26+
2227 final class Any <T > implements AllowedInputs <T > {
2328
2429 private static final @ NotNull Any <Object > NULLABLE = new Any <>(true );
Original file line number Diff line number Diff line change 44import org .jetbrains .annotations .Nullable ;
55
66import java .util .List ;
7+ import java .util .Objects ;
78
89public interface AllowedListInputs <T > extends AllowedInputs <T > {
910
@@ -15,4 +16,38 @@ default boolean isAllowed(@Nullable T input) {
1516 return false ;
1617 return allowedValues ().contains (input );
1718 }
19+
20+ final class Values <T > implements AllowedListInputs <T > {
21+
22+ private final @ NotNull List <T > values ;
23+
24+ Values (@ NotNull List <T > values ) {
25+ this .values = List .copyOf (values );
26+ }
27+
28+ @ Override
29+ public @ NotNull List <T > allowedValues () {
30+ return values ;
31+ }
32+
33+ @ Override
34+ public boolean equals (Object o ) {
35+ if (o == null || getClass () != o .getClass ())
36+ return false ;
37+ Values <?> values1 = (Values <?>) o ;
38+ return Objects .equals (values , values1 .values );
39+ }
40+
41+ @ Override
42+ public int hashCode () {
43+ return Objects .hashCode (values );
44+ }
45+
46+ @ Override
47+ public String toString () {
48+ return "AllowedListInputs$Values{" +
49+ "values=" + values +
50+ '}' ;
51+ }
52+ }
1853}
You can’t perform that action at this time.
0 commit comments