Class CDAClient.Builder

  • Enclosing class:
    CDAClient

    public static class CDAClient.Builder
    extends java.lang.Object
    This builder will be used to configure and then create a CDAClient.
    • Method Detail

      • setSpace

        public CDAClient.Builder setSpace​(java.lang.String space)
        Sets the space ID.
        Parameters:
        space - the space id to be set.
        Returns:
        this builder for chaining.
      • setEnvironment

        public CDAClient.Builder setEnvironment​(java.lang.String environment)
        Sets the environment ID.
        Parameters:
        environment - the space id to be set.
        Returns:
        this builder for chaining.
      • setToken

        public CDAClient.Builder setToken​(java.lang.String token)
        Sets the space access token.
        Parameters:
        token - the access token, sometimes called authorization token.
        Returns:
        this builder for chaining.
      • setEndpoint

        public CDAClient.Builder setEndpoint​(java.lang.String endpoint)
        Sets a custom endpoint.
        Parameters:
        endpoint - the url to be calling to (i.e. https://cdn.contentful.com).
        Returns:
        this builder for chaining.
      • setLogLevel

        public CDAClient.Builder setLogLevel​(Logger.Level logLevel)
        Sets a custom logger level.

        If set to Logger.Level.NONE any custom logger will get ignored.

        Parameters:
        logLevel - the amount/level of logging to be used.
        Returns:
        this builder for chaining.
      • setLogger

        public CDAClient.Builder setLogger​(Logger logger)
        Sets a custom logger.
        Parameters:
        logger - the logger to be set.
        Returns:
        this builder for chaining.
      • preview

        public CDAClient.Builder preview()
        Sets the endpoint to point the Preview API.
        Returns:
        this builder for chaining.
      • setCallFactory

        public CDAClient.Builder setCallFactory​(okhttp3.Call.Factory callFactory)
        Sets a custom HTTP call factory.
        Parameters:
        callFactory - the factory to be used to create a call.
        Returns:
        this builder for chaining.
      • setConverterFactory

        public CDAClient.Builder setConverterFactory​(retrofit2.Converter.Factory converterFactory)
        Sets a custom converter factory.
        Parameters:
        converterFactory - the factory to be used to convert.
        Returns:
        this builder for chaining.
      • defaultCallFactoryBuilder

        public okhttp3.OkHttpClient.Builder defaultCallFactoryBuilder()
        Returns the default Call.Factory.Builder used throughout this SDK.

        Please use this method last in the building step, since changing settings as in the token or others afterwards will not be reflected by this factory.

        This might be useful if you want to augment the default client, without needing to rely on replicating the current sdk behaviour.

        Returns:
        A Call.Factory used through out SDK, as if no custom call factory was used.
      • setTls12Implementation

        public CDAClient.Builder setTls12Implementation​(Tls12Implementation implementation)
        Overwrite the recommendation from the SDK for using a custom TLS12 socket factory.

        This SDK recommends a TLS12 socket factory to be used: Either the system one, or an SDK owned implementation. If this recommendation does not fit your needs, feel free to overwrite the recommendation here.

        Some operation systems and frameworks, esp. Android and Java 1.6, might opt for implementing TLS12 (enforced by Contentful) but do not enable it. The SDK tries to find those situations and recommends to either use the system TLSSocketFactory or a SDK provided one.

        Parameters:
        implementation - which implementation to be used.
        Returns:
        this builder for ease of chaining.
      • setApplication

        public CDAClient.Builder setApplication​(java.lang.String name,
                                                java.lang.String version)
        Tell the client which application this is.

        It might be used for internal tracking of Contentfuls tools.

        Parameters:
        name - the name of the app.
        version - the version in semver of the app.
        Returns:
        this builder for chaining.
      • setIntegration

        public CDAClient.Builder setIntegration​(java.lang.String name,
                                                java.lang.String version)
        Set the name of the integration.

        This custom user agent header will be used for libraries build on top of this library.

        Parameters:
        name - of the integration.
        version - version of the integration.
        Returns:
        this builder for chaining.
      • build

        public CDAClient build()
        Create CDAClient, using the specified configuration options.
        Returns:
        a build CDAClient.