blob: 114e17d195df451ce51d4bd4e99589a78cbd2bb3 (
plain)
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
|
package moe.ymc.acron.config.json;
import com.google.gson.annotations.SerializedName;
import moe.ymc.acron.auth.Action;
import org.jetbrains.annotations.NotNull;
import java.util.regex.Pattern;
class Rule implements ConfigJsonObject<moe.ymc.acron.auth.Rule> {
@SerializedName("regex")
private final String regex;
@SerializedName("action")
private final Action action;
@SerializedName("display")
private final boolean display;
private Rule(String regex,
Action action,
boolean display) {
this.regex = regex;
this.action = action;
this.display = display;
}
public @NotNull moe.ymc.acron.auth.Rule create(boolean startup) throws ConfigDeserializationException {
if (regex == null || regex.trim().equals("") ||
action == null) throw new ConfigDeserializationException(".clients.[]rules.regex or .clients.[]rules.action is" +
"not specified.");
return new moe.ymc.acron.auth.Rule(Pattern.compile(regex),
action,
display);
}
}
|