Package org.fastily.jwiki.core
Class Wiki.Builder
java.lang.Object
org.fastily.jwiki.core.Wiki.Builder
- Enclosing class:
- Wiki
public static class Wiki.Builder extends Object
Builder used to create Wiki objects. All options are optional. If you're lazy and just want an anonymous Wiki pointing to en.wikipedia.org, use
new Wiki.Builder().build()
- Author:
- Fastily
-
Constructor Summary
Constructors Constructor Description Builder()
Creates a new Wiki Builder. -
Method Summary
Modifier and Type Method Description Wiki
build()
Performs the task of creating the Wiki object as configured.Wiki.Builder
withApiEndpoint(okhttp3.HttpUrl apiEndpoint)
Configures the Wiki to be created with the specified api endpoint.Wiki.Builder
withDebug(boolean enableDebug)
Configures the Wiki to be created to print *all* the messages.Wiki.Builder
withDefaultLogger(boolean enableLogging)
Configures the Wiki to use the default jwiki logger.Wiki.Builder
withDomain(String domain)
Configures the Wiki to be created with the specified domain.Wiki.Builder
withLogin(String username, String password)
Configures the Wiki to be created with the specified username and password combination.Wiki.Builder
withProxy(Proxy proxy)
Configures the Wiki to be created with the specified Proxy.Wiki.Builder
withUserAgent(String userAgent)
Configures the Wiki to be created to use the specified User-Agent for HTTP requests.
-
Constructor Details
-
Builder
public Builder()Creates a new Wiki Builder.
-
-
Method Details
-
withUserAgent
Configures the Wiki to be created to use the specified User-Agent for HTTP requests.- Parameters:
userAgent
- The User-Agent to use- Returns:
- This Builder
-
withProxy
Configures the Wiki to be created with the specified Proxy.- Parameters:
proxy
- The Proxy to use- Returns:
- This Builder
-
withApiEndpoint
Configures the Wiki to be created with the specified api endpoint. This is the base endpoint of the MediaWiki instance you are targeting. Example: Wikipedia API.- Parameters:
apiEndpoint
- The base api endpoint to target- Returns:
- This Builder
-
withDomain
Configures the Wiki to be created with the specified domain. This method assumes that the target API endpoint is located athttps://<YOUR_DOMAIN_HERE>/w/api.php
; if this is not the case, then usewithApiEndpoint(HttpUrl)
- Parameters:
domain
- The domain to target. Example:en.wikipedia.org
.- Returns:
- This Builder
-
withDefaultLogger
Configures the Wiki to use the default jwiki logger. This is enabled by default.- Parameters:
enableLogging
- Set false to disable jwiki's built-in logging.- Returns:
- This Builder
-
withLogin
Configures the Wiki to be created with the specified username and password combination. Login will be attempted whenbuild()
is called.- Parameters:
username
- The username to usepassword
- The password to use- Returns:
- This Builder
-
withDebug
Configures the Wiki to be created to print *all* the messages.- Parameters:
enableDebug
- Set true to enable debug mode.- Returns:
- This Builder
-
build
Performs the task of creating the Wiki object as configured. IfwithApiEndpoint(HttpUrl)
orwithDomain(String)
were not called, then the resulting Wiki will default to the Wikipedia API.- Returns:
- A Wiki object
-