Skip to content

Commit 41b3913

Browse files
committed
Add fallback "UNKNOWN" notification type
1 parent 07e35d9 commit 41b3913

1 file changed

Lines changed: 24 additions & 18 deletions

File tree

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
package com.namelessmc.NamelessAPI;
22

33
public class Notification {
4-
5-
private String message;
6-
private String url;
7-
private NotificationType type;
8-
9-
public Notification(String message, String url, NotificationType type) {
4+
5+
private final String message;
6+
private final String url;
7+
private final NotificationType type;
8+
9+
public Notification(final String message, final String url, final NotificationType type) {
1010
this.message = message;
1111
this.url = url;
1212
this.type = type;
1313
}
14-
14+
1515
public String getMessage() {
16-
return message;
16+
return this.message;
1717
}
18-
18+
1919
public String getUrl() {
20-
return url;
20+
return this.url;
2121
}
22-
22+
2323
public NotificationType getType() {
24-
return type;
24+
return this.type;
2525
}
26-
26+
2727
public static enum NotificationType {
2828

2929
TAG,
@@ -32,12 +32,18 @@ public static enum NotificationType {
3232
PROFILE_COMMENT,
3333
COMMENT_REPLY,
3434
THREAD_REPLY,
35-
FOLLOW;
36-
37-
public static NotificationType fromString(String string) {
38-
return NotificationType.valueOf(string.replace('-', '_').toUpperCase());
35+
FOLLOW,
36+
37+
UNKNOWN;
38+
39+
public static NotificationType fromString(final String string) {
40+
try {
41+
return NotificationType.valueOf(string.replace('-', '_').toUpperCase());
42+
} catch (final IllegalArgumentException e) {
43+
return NotificationType.UNKNOWN;
44+
}
3945
}
40-
46+
4147
}
4248

4349
}

0 commit comments

Comments
 (0)