1818package org .botblock .javabotblockapi ;
1919
2020import org .botblock .javabotblockapi .annotations .DeprecatedSince ;
21+ import org .botblock .javabotblockapi .requests .CheckUtil ;
2122import org .botblock .javabotblockapi .requests .PostAction ;
2223import org .jetbrains .annotations .NotNull ;
2324
@@ -104,8 +105,7 @@ public Builder(){}
104105 * @since 2.1.0
105106 */
106107 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" );
109109
110110 tokens .put (site .getSite (), token );
111111
@@ -129,9 +129,9 @@ public Builder addAuthToken(@NotNull Site site, @NotNull String token){
129129 * @return The Builder after the site and token were set. Useful for chaining.
130130 */
131131 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+
135135 tokens .put (site , token );
136136
137137 return this ;
@@ -150,8 +150,7 @@ public Builder addAuthToken(@NotNull String site, @NotNull String token){
150150 * @return The Builder after the Map was set. Useful for chaining.
151151 */
152152 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" );
155154
156155 this .tokens = tokens ;
157156
@@ -165,14 +164,13 @@ public Builder setAuthTokens(@NotNull Map<String, String> tokens){
165164 * @param updateDelay
166165 * The update interval in minutes that should be used. This can't be less than 2.
167166 *
168- * @throws java.lang.IllegalArgumentException
167+ * @throws java.lang.IllegalStateException
169168 * When the updateInterval is less than 2.
170169 *
171170 * @return The Builder after the updateInterval was set. Useful for chaining.
172171 */
173172 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." );
176174
177175 this .updateDelay = updateDelay ;
178176
@@ -181,10 +179,15 @@ public Builder setUpdateDelay(@NotNull Integer updateDelay){
181179
182180 /**
183181 * Builds the instance of {@link org.botblock.javabotblockapi.BotBlockAPI BotBlockAPI}.
182+ *
183+ * @throws java.lang.NullPointerException
184+ * When the Tokens Map is empty.
184185 *
185186 * @return The built, usable {@link org.botblock.javabotblockapi.BotBlockAPI BotBlockAPI}.
186187 */
187188 public BotBlockAPI build (){
189+ CheckUtil .notEmpty (tokens , "Tokens" );
190+
188191 return new BotBlockAPI (tokens , updateDelay );
189192 }
190193 }
0 commit comments