Class Configuration.Builder

java.lang.Object
net.commuty.parking.Configuration.Builder
Enclosing class:
Configuration

public static class Configuration.Builder
extends java.lang.Object
Build a configuration object that will be used ton instantiate a Rest client.

To use this, call Configuration.Builder.create() then chain one or more builder methods.

The only required method is withCredentials(String, String).

  • Method Summary

    Modifier and Type Method Description
    Configuration build()
    Creates a Configuration instance.
    static Configuration buildDefault​(java.lang.String username, java.lang.String password)
    Creates a new configuration instance using default values (default host and no proxy).
    static Configuration.Builder create()  
    Configuration.Builder withCredentials​(java.lang.String username, java.lang.String password)
    Set a username and password to authenticate against the API
    Configuration.Builder withHost​(java.lang.String host)
    Allow you to define a hostname that the client will use.
    Configuration.Builder withProxy​(java.net.Proxy proxy)
    Allow you to define a proxy (if it is required by your organisation).

    Methods inherited from class java.lang.Object

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

    • create

      public static Configuration.Builder create()
    • withCredentials

      public Configuration.Builder withCredentials​(java.lang.String username, java.lang.String password)
      Set a username and password to authenticate against the API

      This was provided to you by Commuty.

      Parameters:
      username - The username Commuty provided to you.
      password - The password Commuty provided to you.
      Returns:
      this builder instance.
    • withHost

      public Configuration.Builder withHost​(java.lang.String host)

      Allow you to define a hostname that the client will use.

      If you do not call this method, the client will use the default production parking api of Commuty.

      Unless the Commuty Team tells you otherwise, you don't need to use this method.

      Parameters:
      host - a valid URL
      Returns:
      this builder instance.
    • withProxy

      public Configuration.Builder withProxy​(java.net.Proxy proxy)

      Allow you to define a proxy (if it is required by your organisation).

      Pass a proxy instance to the method, i.e: new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.0.0.1", 8080));

      Parameters:
      proxy - a valid Proxy object.
      Returns:
      this builder instance.
    • build

      public Configuration build()
      Creates a Configuration instance.
      Returns:
      a new Configuration that will allow you to create a Rest client.
    • buildDefault

      public static Configuration buildDefault​(java.lang.String username, java.lang.String password)

      Creates a new configuration instance using default values (default host and no proxy).

      In most cases, you will need only this method to create a Configuration object.

      Parameters:
      username - The username Commuty provided to you.
      password - The password Commuty provided to you.
      Returns:
      a new Configuration that will allow you to create a Rest client.