Skip to content

Commit 2ccdecd

Browse files
Add result for the non-closable menus API
1 parent 2b755be commit 2ccdecd

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
"\nResult = " + result +
34+
"\nFix: 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+
}

0 commit comments

Comments
 (0)