-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathIScope.java
More file actions
102 lines (84 loc) · 2.16 KB
/
IScope.java
File metadata and controls
102 lines (84 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package xyz.refinedev.phoenix.scope;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public interface IScope {
Pattern SCOPE_REGEX = Pattern.compile("g:[A-Za-z0-9-_]+|s:[A-Za-z0-9-_]+|global");
/**
* Is the scope valid?
*
* @param scope {@link String} Scope
* @return {@link Boolean} Valid
*/
static boolean isValid(String scope) {
return SCOPE_REGEX.matcher(scope).matches();
}
/**
* Get a list of formatted Scopes
*
* @param scopes {@link List <Scope>} Scopes
* @return {@link List<String>} Formatted Scopes
*/
static List<String> toNiceScopes(List<IScope> scopes) {
List<String> niceScopes = new ArrayList<>();
for (IScope scope : scopes) {
niceScopes.add(scope.getDisplayName());
}
return niceScopes;
}
/**
* Is the multiple scope string valid?
*
* @param scopes {@link String} Scopes
* @return {@link Boolean} Valid
*/
static boolean isValidMultiple(String scopes) {
String[] args = scopes.split(";");
if (args.length == 0) return false;
for (String arg : args) {
if (!SCOPE_REGEX.matcher(arg).matches()) return false;
}
return true;
}
/**
* Get the {@link IScope} Display Name
*
* @return {@link String} Display Name
*/
String getDisplayName();
/**
* Is the {@link IScope} a Global Scope?
*
* @return {@link Boolean} Global
*/
boolean isGlobal();
/**
* Is the {@link IScope} a Server Scope?
*
* @return {@link Boolean} Server
*/
boolean isServer();
/**
* Is the {@link IScope} a Group Scope?
*
* @return {@link Boolean} Group
*/
boolean isGroup();
/**
* Get the {@link IScope} Server Name
*
* @return {@link String} Server Name
*/
String getServerName();
/**
* Get the {@link IScope} Group Name
*
* @return {@link String} Group Name
*/
String getGroupName();
@Override
int hashCode();
@Override
boolean equals(Object o);
String getScope();
}