18
18
package org .botblock .javabotblockapi ;
19
19
20
20
import org .botblock .javabotblockapi .annotations .DeprecatedSince ;
21
+ import org .botblock .javabotblockapi .requests .CheckUtil ;
21
22
import org .botblock .javabotblockapi .requests .PostAction ;
22
23
import org .jetbrains .annotations .NotNull ;
23
24
@@ -104,8 +105,7 @@ public Builder(){}
104
105
* @since 2.1.0
105
106
*/
106
107
public Builder addAuthToken (@ NotNull Site site , @ NotNull String token ){
107
- if (token .isEmpty ())
108
- throw new NullPointerException ("Token may not be null." );
108
+ CheckUtil .notEmpty (token , "Token" );
109
109
110
110
tokens .put (site .getSite (), token );
111
111
@@ -129,9 +129,9 @@ public Builder addAuthToken(@NotNull Site site, @NotNull String token){
129
129
* @return The Builder after the site and token were set. Useful for chaining.
130
130
*/
131
131
public Builder addAuthToken (@ NotNull String site , @ NotNull String token ){
132
- if ( site . isEmpty () || token . isEmpty ())
133
- throw new NullPointerException ( "Site and/or token may not be null. " );
134
-
132
+ CheckUtil . notEmpty ( site , "Site" );
133
+ CheckUtil . notEmpty ( token , "Token " );
134
+
135
135
tokens .put (site , token );
136
136
137
137
return this ;
@@ -150,8 +150,7 @@ public Builder addAuthToken(@NotNull String site, @NotNull String token){
150
150
* @return The Builder after the Map was set. Useful for chaining.
151
151
*/
152
152
public Builder setAuthTokens (@ NotNull Map <String , String > tokens ){
153
- if (tokens .isEmpty ())
154
- throw new NullPointerException ("Tokens may not be empty." );
153
+ CheckUtil .notEmpty (tokens , "Tokens" );
155
154
156
155
this .tokens = tokens ;
157
156
@@ -165,14 +164,13 @@ public Builder setAuthTokens(@NotNull Map<String, String> tokens){
165
164
* @param updateDelay
166
165
* The update interval in minutes that should be used. This can't be less than 2.
167
166
*
168
- * @throws java.lang.IllegalArgumentException
167
+ * @throws java.lang.IllegalStateException
169
168
* When the updateInterval is less than 2.
170
169
*
171
170
* @return The Builder after the updateInterval was set. Useful for chaining.
172
171
*/
173
172
public Builder setUpdateDelay (@ NotNull Integer updateDelay ){
174
- if (updateDelay < 2 )
175
- throw new IllegalArgumentException ("Update interval may not be less than 2." );
173
+ CheckUtil .condition (updateDelay < 2 , "UpdateDelay may not be less than 2." );
176
174
177
175
this .updateDelay = updateDelay ;
178
176
@@ -181,10 +179,15 @@ public Builder setUpdateDelay(@NotNull Integer updateDelay){
181
179
182
180
/**
183
181
* Builds the instance of {@link org.botblock.javabotblockapi.BotBlockAPI BotBlockAPI}.
182
+ *
183
+ * @throws java.lang.NullPointerException
184
+ * When the Tokens Map is empty.
184
185
*
185
186
* @return The built, usable {@link org.botblock.javabotblockapi.BotBlockAPI BotBlockAPI}.
186
187
*/
187
188
public BotBlockAPI build (){
189
+ CheckUtil .notEmpty (tokens , "Tokens" );
190
+
188
191
return new BotBlockAPI (tokens , updateDelay );
189
192
}
190
193
}
0 commit comments