Class ExonumClient.Builder

java.lang.Object
com.exonum.client.ExonumClient.Builder
Enclosing interface:
ExonumClient

public static class ExonumClient.Builder
extends java.lang.Object
Builder class for the Exonum client.
  • Constructor Summary

    Constructors 
    Constructor Description
    Builder()  
  • Method Summary

    Modifier and Type Method Description
    ExonumClient build()
    Creates Exonum client instance.
    ExonumClient.Builder setExonumHost​(java.lang.String exonumHost)
    Sets the Exonum host url.
    ExonumClient.Builder setExonumHost​(java.net.URL exonumHost)
    Sets the Exonum host url.
    ExonumClient.Builder setHttpClient​(okhttp3.OkHttpClient client)
    Sets http client, optional.
    ExonumClient.Builder setPrefix​(java.lang.String prefix)
    Sets an optional URL prefix to be applied to all requests made by the client.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • setExonumHost

      public ExonumClient.Builder setExonumHost​(java.net.URL exonumHost)
      Sets the Exonum host url.
      Parameters:
      exonumHost - Exonum public API address
      See Also:
      API Configuration, Exonum Node Configuraion
    • setExonumHost

      public ExonumClient.Builder setExonumHost​(java.lang.String exonumHost)
      Sets the Exonum host url.
      Parameters:
      exonumHost - Exonum public API address
      Throws:
      java.lang.IllegalArgumentException - if the url is malformed
      See Also:
      setExonumHost(URL)
    • setHttpClient

      public ExonumClient.Builder setHttpClient​(okhttp3.OkHttpClient client)
      Sets http client, optional. If not set a default instance of http client will be used.

      This method provides a flexibility for the Exonum client configuration. Can be helpful, for example, in case a network proxy configuration is needed or request/response logging.

    • setPrefix

      public ExonumClient.Builder setPrefix​(java.lang.String prefix)
      Sets an optional URL prefix to be applied to all requests made by the client. Can be helpful in case of using middleware routing proxy on the blockchain node side. There is no prefix by default.
    • build

      public ExonumClient build()
      Creates Exonum client instance.
      Throws:
      java.lang.IllegalStateException - if required fields weren't set