Skip to content

Commit 01121e4

Browse files
committed
Turn Site enum into a class
1 parent 371b24b commit 01121e4

File tree

13 files changed

+163
-183
lines changed

13 files changed

+163
-183
lines changed

core/src/main/java/org/botblock/javabotblockapi/core/BotBlockAPI.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ public class BotBlockAPI{
3737
private final int updateDelay;
3838

3939
private BotBlockAPI(@Nonnull Map<String, String> tokens, int updateDelay){
40-
if(tokens.isEmpty())
41-
throw new NullPointerException("Tokens may not be empty.");
42-
43-
if(updateDelay < 2)
44-
throw new IllegalArgumentException("UpdateDelay may not be less than 2.");
40+
CheckUtil.notEmpty(tokens, "Tokens");
41+
CheckUtil.condition(updateDelay < 2, "UpdateDelay may not be less than 2");
4542

4643
this.tokens = tokens;
4744
this.updateDelay = updateDelay;
@@ -68,11 +65,11 @@ public static class Builder{
6865
public Builder(){}
6966

7067
/**
71-
* Adds the provided {@link org.botblock.javabotblockapi.core.Site Site name} and token to the Map.
68+
* Adds the provided {@link SiteOld Site name} and token to the Map.
7269
* <br>Entries with the same key will be overwritten.
7370
*
7471
* @param site
75-
* The {@link org.botblock.javabotblockapi.core.Site Site} to get the name from.
72+
* The {@link Site Site} to get the name from.
7673
* @param token
7774
* The API token from the corresponding bot list. May not be null or empty.
7875
* <br>You may receive the API token from the bot list.
@@ -89,9 +86,9 @@ public Builder(){}
8986
*/
9087
public Builder addAuthToken(@Nonnull Site site, @Nonnull String token){
9188
CheckUtil.notEmpty(token, "Token");
92-
CheckUtil.condition(!site.supportsPost(), site.getSite() + " does not support POST requests!");
89+
CheckUtil.condition(!site.supportsPost(), site.getName() + " does not support POST requests!");
9390

94-
tokens.put(site.getSite(), token);
91+
tokens.put(site.getName(), token);
9592
return this;
9693
}
9794

@@ -106,8 +103,10 @@ public Builder addAuthToken(@Nonnull Site site, @Nonnull String token){
106103
* The API token from the corresponding bot list. May not be null or empty.
107104
* <br>You may receive the API token from the bot list.
108105
*
109-
* @throws java.lang.NullPointerException
110-
* When either the site or token are empty ({@code ""}).
106+
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
107+
* <ul>
108+
* <li>{@link java.lang.NullPointerException NullPointerException} - When the provided Site or Token is empty.</li>
109+
* </ul>
111110
*
112111
* @return The Builder after the site and token were set. Useful for chaining.
113112
*/
@@ -126,8 +125,10 @@ public Builder addAuthToken(@Nonnull String site, @Nonnull String token){
126125
* @param tokens
127126
* The Map that should be used. May not be null.
128127
*
129-
* @throws java.lang.NullPointerException
130-
* When the provided Map is empty.
128+
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
129+
* <ul>
130+
* <li>{@link java.lang.NullPointerException NullPointerException} - When the provided Token is empty.</li>
131+
* </ul>
131132
*
132133
* @return The Builder after the Map was set. Useful for chaining.
133134
*/
@@ -145,8 +146,10 @@ public Builder setAuthTokens(@Nonnull Map<String, String> tokens){
145146
* @param updateDelay
146147
* The update interval in minutes that should be used. This can't be less than 2.
147148
*
148-
* @throws java.lang.IllegalStateException
149-
* When the updateInterval is less than 2.
149+
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
150+
* <ul>
151+
* <li>{@link java.lang.IllegalStateException IllegalStateException} - When the provided interval is less than 2.</li>
152+
* </ul>
150153
*
151154
* @return The Builder after the updateInterval was set. Useful for chaining.
152155
*/
@@ -160,8 +163,10 @@ public Builder setUpdateDelay(@Nonnull Integer updateDelay){
160163
/**
161164
* Builds the instance of {@link org.botblock.javabotblockapi.core.BotBlockAPI BotBlockAPI}.
162165
*
163-
* @throws java.lang.NullPointerException
164-
* When the Tokens Map is empty.
166+
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
167+
* <ul>
168+
* <li>{@link java.lang.NullPointerException NullPointerException} - When the Tokens Map is empty.</li>
169+
* </ul>
165170
*
166171
* @return The built, usable {@link org.botblock.javabotblockapi.core.BotBlockAPI BotBlockAPI}.
167172
*/

core/src/main/java/org/botblock/javabotblockapi/core/CheckUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.Map;
2222

2323
/**
24-
* Util class to perform basic checks.
24+
* Utility class to perform basic checks.
2525
*/
2626
public class CheckUtil{
2727

0 commit comments

Comments
 (0)