Class BotBlockAPI.Builder
- java.lang.Object
-
- org.botblock.javabotblockapi.core.BotBlockAPI.Builder
-
- Enclosing class:
- BotBlockAPI
public static class BotBlockAPI.Builder extends Object
Builder class to create an instance ofBotBlockAPI
-
-
Constructor Summary
Constructors Constructor Description Builder()
Empty constructor to get the class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BotBlockAPI.Builder
addAuthToken(String site, String token)
Adds the provided Site name and token to the Map.BotBlockAPI.Builder
addAuthToken(Site site, String token)
Adds the providedSite name
and token to the Map.BotBlockAPI
build()
Builds the instance ofBotBlockAPI
.BotBlockAPI.Builder
setAuthTokens(Map<String,String> tokens)
Sets the provided Map as the new Map.BotBlockAPI.Builder
setUpdateDelay(Integer updateDelay)
Sets the update delay (in minutes) for the auto-posting.
-
-
-
Method Detail
-
addAuthToken
public BotBlockAPI.Builder addAuthToken(@Nonnull Site site, @Nonnull String token)
Adds the providedSite name
and token to the Map.
Entries with the same key will be overwritten.- Parameters:
site
- TheSite
to get the name from.token
- The API token from the corresponding bot list. May not be null or empty.
You may receive the API token from the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException
- When the provided Token is empty.IllegalStateException
- When the provided Site doesn't support POST requests.
- Returns:
- The Builder after the site and token were set. Useful for chaining.
- Since:
- 2.1.0
-
addAuthToken
public BotBlockAPI.Builder addAuthToken(@Nonnull String site, @Nonnull String token)
Adds the provided Site name and token to the Map.
Entries with the same key will be overwritten.- Parameters:
site
- The name of the site. May not be null or empty.
A list of supported sites can be found here.token
- The API token from the corresponding bot list. May not be null or empty.
You may receive the API token from the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException
- When the provided Site or Token is empty.
- Returns:
- The Builder after the site and token were set. Useful for chaining.
-
setAuthTokens
public BotBlockAPI.Builder setAuthTokens(@Nonnull Map<String,String> tokens)
Sets the provided Map as the new Map.
This will overwrite every previously set entry!- Parameters:
tokens
- The Map that should be used. May not be null.Following Exceptions can be thrown from the CheckUtil:
NullPointerException
- When the provided Token is empty.
- Returns:
- The Builder after the Map was set. Useful for chaining.
-
setUpdateDelay
public BotBlockAPI.Builder setUpdateDelay(@Nonnull Integer updateDelay)
Sets the update delay (in minutes) for the auto-posting.
You don't need to set this when not using the auto-post option. Default is 30.- Parameters:
updateDelay
- The update interval in minutes that should be used. This can't be less than 2.Following Exceptions can be thrown from the CheckUtil:
IllegalStateException
- When the provided interval is less than 2.
- Returns:
- The Builder after the updateInterval was set. Useful for chaining.
-
build
public BotBlockAPI build()
Builds the instance ofBotBlockAPI
.Following Exceptions can be thrown from the CheckUtil:
NullPointerException
- When the Tokens Map is empty.
- Returns:
- The built, usable
BotBlockAPI
.
-
-