Skip to content

Commit

Permalink
Add Discord-Only token type, improve enum build code
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyborger1 committed Jun 18, 2021
1 parent 47c2b56 commit 51f38fe
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/main/java/com/botdetector/model/AuthTokenType.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,45 @@
package com.botdetector.model;

import com.google.common.collect.ImmutableSet;
import java.util.Arrays;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import static com.botdetector.model.AuthTokenPermission.*;

@Getter
@RequiredArgsConstructor
public enum AuthTokenType
{
/**
* No permissions
*/
NONE(ImmutableSet.of()),
NONE(),

/**
* All permissions
*/
DEV(Arrays.stream(AuthTokenPermission.values()).collect(ImmutableSet.toImmutableSet())),
DEV(AuthTokenPermission.values()),

/**
* Can perform discord verification and retrieve clan rank updates
*/
MOD(ImmutableSet.of(VERIFY_DISCORD, GET_CLAN_RANK_UPDATES)),
MOD(VERIFY_DISCORD, GET_CLAN_RANK_UPDATES),

/**
* Can perform discord verification
*/
DISCORD(VERIFY_DISCORD),

/**
* Can retrieve clan rank updates
*/
CLAN(ImmutableSet.of(GET_CLAN_RANK_UPDATES))
CLAN(GET_CLAN_RANK_UPDATES)
;

private final ImmutableSet<AuthTokenPermission> permissions;

AuthTokenType(AuthTokenPermission... permissions)
{
this.permissions = ImmutableSet.copyOf(permissions);
}

/**
* Parses the token type from the given {@code prefix}.
* @param prefix The prefix to parse.
Expand Down

0 comments on commit 51f38fe

Please sign in to comment.