Package org.eu.zajc.akiwrapper
Class AkiwrapperBuilder
java.lang.Object
org.eu.zajc.akiwrapper.AkiwrapperBuilder
A class used to build an
Akiwrapper object.- Author:
- Marko Zajc
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanThe default profanity filter preference for newAkiwrapperinstances.static final Akiwrapper.ThemeDeprecated, for removal: This API element is subject to removal in a future version.static final Akiwrapper.LanguageThe defaultAkiwrapper.Languagefor newAkiwrapperinstances.static final Akiwrapper.ThemeThe defaultAkiwrapper.Themefor newAkiwrapperinstances. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newAkiwrapperBuilderwith the following defaults: profanity filtering is set tofalse(DEFAULT_FILTER_PROFANITY), language is set toAkiwrapper.Language.ENGLISH(DEFAULT_LANGUAGE), theme is set toAkiwrapper.Theme.CHARACTER(DEFAULT_GUESS_TYPE), -
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates a newAkiwrapperinstance from your preferences.booleanReturns the profanity filter preference.Deprecated, for removal: This API element is subject to removal in a future version.UsegetTheme()instead.Note: while allAkiwrapper.Languages supportAkiwrapper.Theme.CHARACTER, but other themes might not be supported.getTheme()Note: while allAkiwrapper.Languages supportAkiwrapper.Theme.CHARACTER, but other themes might not be supported.kong.unirest.UnirestInstanceReturns theUnirestInstanceto be used by the built Akiwrapper instance.setFilterProfanity(boolean filterProfanity) Sets the profanity filter preference.setGuessType(Akiwrapper.Theme theme) Deprecated, for removal: This API element is subject to removal in a future version.UsesetTheme(Theme)insteadsetLanguage(Akiwrapper.Language language) Note: while allAkiwrapper.Languages supportAkiwrapper.Theme.CHARACTER, but other themes might not be supported.setTheme(Akiwrapper.Theme theme) Note: while allAkiwrapper.Languages supportAkiwrapper.Theme.CHARACTER, but other themes might not be supported.setUnirestInstance(kong.unirest.UnirestInstance unirest) Sets theUnirestInstanceto be used by the built Akiwrapper instance.
-
Field Details
-
DEFAULT_FILTER_PROFANITY
public static final boolean DEFAULT_FILTER_PROFANITYThe default profanity filter preference for newAkiwrapperinstances.- See Also:
-
DEFAULT_LANGUAGE
The defaultAkiwrapper.Languagefor newAkiwrapperinstances. -
DEFAULT_THEME
The defaultAkiwrapper.Themefor newAkiwrapperinstances. -
DEFAULT_GUESS_TYPE
@Deprecated(since="2.0", forRemoval=true) @Nonnull public static final Akiwrapper.Theme DEFAULT_GUESS_TYPEDeprecated, for removal: This API element is subject to removal in a future version.UseDEFAULT_THEMEinsteadThe defaultAkiwrapper.Themefor newAkiwrapperinstances.
-
-
Constructor Details
-
AkiwrapperBuilder
public AkiwrapperBuilder()Creates a newAkiwrapperBuilderwith the following defaults:- profanity filtering is set to
false(DEFAULT_FILTER_PROFANITY), - language is set to
Akiwrapper.Language.ENGLISH(DEFAULT_LANGUAGE), - theme is set to
Akiwrapper.Theme.CHARACTER(DEFAULT_GUESS_TYPE),
- profanity filtering is set to
-
-
Method Details
-
setUnirestInstance
@Nonnull public AkiwrapperBuilder setUnirestInstance(@Nullable kong.unirest.UnirestInstance unirest) Sets theUnirestInstanceto be used by the built Akiwrapper instance. Note that Akinator's services are quite picky about the HTTP client configuration, so you will very likely need to put your instance throughUnirestUtils.configureInstance(UnirestInstance)before using it with Akiwrapper. You will also need to shut it down yourself, or, if you decide to set or leave this on {$code null}, callUnirestUtils.shutdownInstance()to shut down Akiwrapper's default singleton instance, otherwise its threads will stay alive.- Parameters:
unirest- theUnirestInstanceto be used by Akiwrapper or {$code null} to useUnirestUtils.getInstance().- Returns:
- current instance, used for chaining.
- See Also:
-
getUnirestInstance
@Nullable public kong.unirest.UnirestInstance getUnirestInstance()Returns theUnirestInstanceto be used by the built Akiwrapper instance. If this is {$code null},UnirestUtils.getInstance()will be used (which means you will need to shut it down throughUnirestUtils.shutdownInstance(), otherwise its threads will stay alive).- Returns:
UnirestInstanceto be used or {$code null} forUnirestUtils.getInstance().
-
setFilterProfanity
Sets the profanity filter preference. Profanity filtering is done by Akinator and not by Akiwrapper. Keep in mind that Akinator's filters aren't perfect, so explicitQueryobjects can still be returned.
This is set tofalseby default.- Parameters:
filterProfanity-- Returns:
- current instance, used for chaining.
- See Also:
-
doesFilterProfanity
public boolean doesFilterProfanity()Returns the profanity filter preference. Profanity filtering is done by Akinator and not by Akiwrapper. Keep in mind that Akinator's filters aren't perfect, so explicitQueryobjects can still be returned.
This is set tofalseby default.- Returns:
- profanity filter preference.
-
setLanguage
Note: while allAkiwrapper.Languages supportAkiwrapper.Theme.CHARACTER, but other themes might not be supported. CallAkiwrapper.Language.getSupportedThemes()for a list of supported themes.
Sets theAkiwrapper.Language. Akinator will return localizedQueryobjects depending on this preference.
This is set toAkiwrapper.Language.ENGLISHby default.- Parameters:
language-- Returns:
- current instance, used for chaining.
- See Also:
-
getLanguage
Note: while allAkiwrapper.Languages supportAkiwrapper.Theme.CHARACTER, but other themes might not be supported. CallAkiwrapper.Language.getSupportedThemes()for a list of supported themes.
Sets theAkiwrapper.Language. Akinator will return localizedQueryobjects depending on this preference.
This is set toAkiwrapper.Language.ENGLISHby default.- Returns:
- language preference.
- See Also:
-
setTheme
Note: while allAkiwrapper.Languages supportAkiwrapper.Theme.CHARACTER, but other themes might not be supported. CallAkiwrapper.Language.getSupportedThemes()for a list of supported themes.
Sets theAkiwrapper.Theme. This decides the theme of Akinator'sQueryobjects.
This is set toAkiwrapper.Theme.CHARACTERby default.- Parameters:
theme-- Returns:
- current instance, used for chaining.
- See Also:
-
setGuessType
@Nonnull @Deprecated(since="2.0", forRemoval=true) public AkiwrapperBuilder setGuessType(@Nonnull Akiwrapper.Theme theme) Deprecated, for removal: This API element is subject to removal in a future version.UsesetTheme(Theme)insteadNote: while allAkiwrapper.Languages supportAkiwrapper.Theme.CHARACTER, but other themes might not be supported. CallAkiwrapper.Language.getSupportedThemes()for a list of supported themes.
Sets theAkiwrapper.Theme. This decides the theme of Akinator'sQueryobjects.
This is set toAkiwrapper.Theme.CHARACTERby default.- Parameters:
theme-- Returns:
- current instance, used for chaining.
- See Also:
-
getTheme
Note: while allAkiwrapper.Languages supportAkiwrapper.Theme.CHARACTER, but other themes might not be supported. CallAkiwrapper.Language.getSupportedThemes()for a list of supported themes.
Sets theAkiwrapper.Theme. This decides the theme of Akinator'sQueryobjects.
This is set toAkiwrapper.Theme.CHARACTERby default.- Returns:
- theme preference.
- See Also:
-
getGuessType
Deprecated, for removal: This API element is subject to removal in a future version.UsegetTheme()instead.Note: while allAkiwrapper.Languages supportAkiwrapper.Theme.CHARACTER, but other themes might not be supported. CallAkiwrapper.Language.getSupportedThemes()for a list of supported themes.
Sets theAkiwrapper.Theme. This decides the theme of Akinator'sQueryobjects.
This is set toAkiwrapper.Theme.CHARACTERby default.- Returns:
- theme preference.
- See Also:
-
build
Creates a newAkiwrapperinstance from your preferences. If noUnirestInstancewas set (withsetUnirestInstance(UnirestInstance)), a singleton instance will be acquired fromUnirestUtils.getInstance(). This instance must be shut down after you're done using Akiwrapper withUnirestUtils.shutdownInstance(), otherwise its threads will stay alive.- Returns:
- a new
Akiwrapperinstance. - Throws:
LanguageThemeCombinationException- if theAkiwrapper.LanguageandAkiwrapper.Themecombination is incompatible.
-
DEFAULT_THEMEinstead