File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
src/main/java/me/flame/menus/menu Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ package me .flame .menus .menu ;
2
+
3
+ import lombok .NonNull ;
4
+
5
+ public class Result {
6
+ public String result ;
7
+ private static final String DENIED = "denied" ;
8
+ private static final String ALLOWED = "allowed" ;
9
+
10
+ private Result (String result ) {
11
+ this .result = result ;
12
+ }
13
+
14
+ public boolean equals (Object o ) {
15
+ if (!(o instanceof Result )) return false ;
16
+ Result r = (Result ) o ;
17
+ return result .equals (r .result );
18
+ }
19
+
20
+ public static Result denied () {
21
+ return new Result (DENIED );
22
+ }
23
+
24
+ public static Result allowed () {
25
+ return new Result (ALLOWED );
26
+ }
27
+
28
+ public void set (@ NonNull Result r ) {
29
+ String result = r .result ;
30
+ if (!result .equals (DENIED ) && !result .equals (ALLOWED ))
31
+ throw new IllegalArgumentException (
32
+ "Must be 'allowed' or 'denied'" +
33
+ "\n Result = " + result +
34
+ "\n Fix: Change the result to 'allowed' or 'denied'"
35
+ );
36
+ this .result = result ;
37
+ }
38
+
39
+ public boolean isDenied () {
40
+ return result .equals (DENIED );
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments