Skip to content

Commit 51f38fe

Browse files
committed
Add Discord-Only token type, improve enum build code
1 parent 47c2b56 commit 51f38fe

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/main/java/com/botdetector/model/AuthTokenType.java

+14-7
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,45 @@
2626
package com.botdetector.model;
2727

2828
import com.google.common.collect.ImmutableSet;
29-
import java.util.Arrays;
3029
import lombok.Getter;
31-
import lombok.RequiredArgsConstructor;
3230
import static com.botdetector.model.AuthTokenPermission.*;
3331

3432
@Getter
35-
@RequiredArgsConstructor
3633
public enum AuthTokenType
3734
{
3835
/**
3936
* No permissions
4037
*/
41-
NONE(ImmutableSet.of()),
38+
NONE(),
4239

4340
/**
4441
* All permissions
4542
*/
46-
DEV(Arrays.stream(AuthTokenPermission.values()).collect(ImmutableSet.toImmutableSet())),
43+
DEV(AuthTokenPermission.values()),
4744

4845
/**
4946
* Can perform discord verification and retrieve clan rank updates
5047
*/
51-
MOD(ImmutableSet.of(VERIFY_DISCORD, GET_CLAN_RANK_UPDATES)),
48+
MOD(VERIFY_DISCORD, GET_CLAN_RANK_UPDATES),
49+
50+
/**
51+
* Can perform discord verification
52+
*/
53+
DISCORD(VERIFY_DISCORD),
5254

5355
/**
5456
* Can retrieve clan rank updates
5557
*/
56-
CLAN(ImmutableSet.of(GET_CLAN_RANK_UPDATES))
58+
CLAN(GET_CLAN_RANK_UPDATES)
5759
;
5860

5961
private final ImmutableSet<AuthTokenPermission> permissions;
6062

63+
AuthTokenType(AuthTokenPermission... permissions)
64+
{
65+
this.permissions = ImmutableSet.copyOf(permissions);
66+
}
67+
6168
/**
6269
* Parses the token type from the given {@code prefix}.
6370
* @param prefix The prefix to parse.

0 commit comments

Comments
 (0)