File tree Expand file tree Collapse file tree 3 files changed +46
-33
lines changed
src/main/java/io/mailtrap/model/response Expand file tree Collapse file tree 3 files changed +46
-33
lines changed Original file line number Diff line number Diff line change
1
+ package io .mailtrap .model .response ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonCreator ;
4
+ import com .fasterxml .jackson .annotation .JsonValue ;
5
+ import lombok .Getter ;
6
+
7
+ public enum AccessLevel {
8
+
9
+ OWNER (1000 , "owner" ),
10
+ ADMIN (100 , "admin" ),
11
+ VIEWER (10 , "viewer" ),
12
+ INDETERMINATE (1 , "indeterminate" );
13
+
14
+ @ Getter
15
+ private final int intValue ;
16
+ private final String stringValue ;
17
+
18
+ AccessLevel (int intValue , String stringValue ) {
19
+ this .intValue = intValue ;
20
+ this .stringValue = stringValue ;
21
+ }
22
+
23
+ @ JsonValue
24
+ public String getStringValue () {
25
+ return stringValue ;
26
+ }
27
+
28
+ @ JsonCreator
29
+ public static AccessLevel fromValue (Object value ) {
30
+ if (value instanceof Integer ) {
31
+ for (AccessLevel level : AccessLevel .values ()) {
32
+ if (level .intValue == (Integer ) value ) {
33
+ return level ;
34
+ }
35
+ }
36
+ } else if (value instanceof String ) {
37
+ for (AccessLevel level : AccessLevel .values ()) {
38
+ if (level .stringValue .equalsIgnoreCase ((String ) value )) {
39
+ return level ;
40
+ }
41
+ }
42
+ }
43
+ throw new IllegalArgumentException ("Unknown value: " + value );
44
+ }
45
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
package io .mailtrap .model .response .account_accesses ;
2
2
3
3
import com .fasterxml .jackson .annotation .JsonProperty ;
4
+ import io .mailtrap .model .response .AccessLevel ;
4
5
import lombok .Data ;
5
6
6
7
@ Data
You can’t perform that action at this time.
0 commit comments