Skip to content

Commit 34fe09f

Browse files
committed
fix: unused private constructor
1 parent 4af9fed commit 34fe09f

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

application/src/main/java/org/togetherjava/tjbot/config/CoolMessagesBoardConfig.java

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,24 @@
33
import com.fasterxml.jackson.annotation.JsonProperty;
44
import com.fasterxml.jackson.annotation.JsonRootName;
55

6+
import java.util.Objects;
7+
68
/**
79
* Configuration for the cool messages board feature, see
810
* {@link org.togetherjava.tjbot.features.basic.CoolMessagesBoardManager}.
911
*/
1012
@JsonRootName("coolMessagesConfig")
11-
public final class CoolMessagesBoardConfig {
12-
private final String boardChannelPattern;
13-
private final int minimumReactions;
14-
15-
private CoolMessagesBoardConfig(
16-
@JsonProperty(value = "minimumReactions", required = true) int minimumReactions,
17-
@JsonProperty(value = "boardChannelPattern",
18-
required = true) String boardChannelPattern) {
19-
this.minimumReactions = minimumReactions;
20-
this.boardChannelPattern = boardChannelPattern;
21-
}
22-
23-
/**
24-
* Gets the minimum amount of reactions needed for a message to be considered as a quote.
25-
*
26-
* @return the minimum amount of reactions
27-
*/
28-
public int getMinimumReactions() {
29-
return minimumReactions;
30-
}
13+
public record CoolMessagesBoardConfig(
14+
@JsonProperty(value = "minimumReactions", required = true) int minimumReactions,
15+
@JsonProperty(value = "boardChannelPattern", required = true) String boardChannelPattern) {
3116

3217
/**
33-
* Gets the REGEX pattern used to identify the quotes text channel
18+
* Creates a CoolMessagesBoardConfig.
3419
*
35-
* @return the channel name pattern
20+
* @param minimumReactions the minimum amount of reactions
21+
* @param boardChannelPattern the pattern for the board channel
3622
*/
37-
public String getBoardChannelPattern() {
38-
return boardChannelPattern;
23+
public CoolMessagesBoardConfig {
24+
Objects.requireNonNull(boardChannelPattern);
3925
}
4026
}

application/src/main/java/org/togetherjava/tjbot/features/basic/CoolMessagesBoardManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public CoolMessagesBoardManager(Config config) {
3737
this.config = config.getCoolMessagesConfig();
3838

3939
boardChannelNamePredicate =
40-
Pattern.compile(this.config.getBoardChannelPattern()).asMatchPredicate();
40+
Pattern.compile(this.config.boardChannelPattern()).asMatchPredicate();
4141
}
4242

4343
@Override
@@ -54,7 +54,7 @@ public void onMessageReactionAdd(MessageReactionAddEvent event) {
5454
return;
5555
}
5656

57-
if (isCoolEmoji && originalReactionsCount + 1 >= config.getMinimumReactions()) {
57+
if (isCoolEmoji && originalReactionsCount + 1 >= config.minimumReactions()) {
5858
event.retrieveMessage()
5959
.queue(message -> insertCoolMessage(boardChannel.orElseThrow(), message),
6060
e -> logger.warn("Tried to retrieve cool message but got: {}",

0 commit comments

Comments
 (0)