Skip to content

Commit da95a55

Browse files
committed
Move the logic to CheckUtil
1 parent b60b483 commit da95a55

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public Builder(){}
8383
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
8484
* <ul>
8585
* <li>{@link java.lang.NullPointerException NullPointerException} - When the provided Token is empty.</li>
86+
* <li>{@link java.lang.IllegalStateException IllegalStateException} - When the provided Site doesn't support POST requests.</li>
8687
* </ul>
8788
*
8889
* @return The Builder after the site and token were set. Useful for chaining.
@@ -91,16 +92,7 @@ public Builder(){}
9192
*/
9293
public Builder addAuthToken(@Nonnull Site site, @Nonnull String token){
9394
CheckUtil.notEmpty(token, "Token");
94-
95-
Field field;
96-
try{
97-
field = site.getClass().getField(site.name());
98-
}catch(NoSuchFieldException ex){
99-
field = null;
100-
}
101-
102-
if(field == null || !field.isAnnotationPresent(Post.class))
103-
throw new IllegalStateException("The provided Site instance is not allowed for POST Actions!");
95+
CheckUtil.supportsPost(site);
10496

10597
tokens.put(site.getSite(), token);
10698
return this;

0 commit comments

Comments
 (0)