Class UnirestUtils

java.lang.Object
org.eu.zajc.akiwrapper.core.utils.UnirestUtils

public class UnirestUtils extends Object
Various utilities regarding Unirest for use with and within Akiwrapper.
Author:
Marko Zajc
  • Method Summary

    Modifier and Type
    Method
    Description
    static kong.unirest.UnirestInstance
    configureInstance(kong.unirest.UnirestInstance unirest)
    Note: even though this method returns a UnirestInstance, the instance you pass to it is itself mutated and returned.
    static kong.unirest.UnirestInstance
    Returns the singleton UnirestInstance or creates one if it's null.
    static void
    Shuts down the singleton UnirestInstance, if it's present, and does nothing otherwise.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getInstance

      @Nonnull public static kong.unirest.UnirestInstance getInstance()
      Returns the singleton UnirestInstance or creates one if it's null. Note that UnirestInstances need to be shut down after they're not needed anymore, so make sure to call shutdownInstance() after you're done with it. Attempting to shut it down manually through UnirestInstance.shutDown() may cause issues, so don't do that!
      Returns:
      the singleton UnirestInstance
    • shutdownInstance

      public static void shutdownInstance()
      Shuts down the singleton UnirestInstance, if it's present, and does nothing otherwise. Subsequent calls to getInstance() will recreate it.
    • configureInstance

      @Nonnull public static kong.unirest.UnirestInstance configureInstance(kong.unirest.UnirestInstance unirest)
      Note: even though this method returns a UnirestInstance, the instance you pass to it is itself mutated and returned. The return value is only there for ease of chaining. Configures a new UnirestInstance for use by Akiwrapper.

      Akinator's API servers are quite picky about the headers you send to them so if you supply AkiwrapperBuilder with your own UnirestInstance you should either pass it through this or configure it accordingly yourself.
      Parameters:
      unirest - the UnirestInstance to configure
      Returns:
      the UnirestInstance you passed, used for chaining