All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hivemq.client.mqtt.MqttClientBuilderBase Maven / Gradle / Ivy

Go to download

HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support

There is a newer version: 1.3.3
Show newest version
/*
 * Copyright 2018 dc-square and the HiveMQ MQTT Client Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.hivemq.client.mqtt;

import com.hivemq.client.annotations.DoNotImplement;
import com.hivemq.client.mqtt.datatypes.MqttClientIdentifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * Builder base for a {@link MqttClient}.
 *
 * @param  the type of the builder.
 * @author Silvio Giebl
 * @since 1.0
 */
@DoNotImplement
public interface MqttClientBuilderBase> {

    /**
     * Sets the {@link MqttClientConfig#getClientIdentifier() Client Identifier}.
     *
     * @param identifier the string representation of the Client Identifier.
     * @return the builder.
     */
    @NotNull B identifier(@NotNull String identifier);

    /**
     * Sets the {@link MqttClientConfig#getClientIdentifier() Client Identifier}.
     *
     * @param identifier the Client Identifier.
     * @return the builder.
     */
    @NotNull B identifier(@NotNull MqttClientIdentifier identifier);

    /**
     * Sets the {@link MqttClientConfig#getServerHost() server host} to connect to.
     *
     * @param host the server host.
     * @return the builder.
     */
    @NotNull B serverHost(@NotNull String host);

    /**
     * Sets the {@link MqttClientConfig#getServerPort() server port} to connect to.
     *
     * @param port the server port.
     * @return the builder.
     */
    @NotNull B serverPort(int port);

    /**
     * Uses SSL with the default configuration.
     *
     * @return the builder.
     */
    @NotNull B useSslWithDefaultConfig();

    /**
     * Sets the optional {@link MqttClientConfig#getSslConfig() SSL configuration}.
     *
     * @param sslConfig the SSL configuration or null to remove any previously set SSL configuration.
     * @return the builder.
     */
    @NotNull B useSsl(@Nullable MqttClientSslConfig sslConfig);

    /**
     * Fluent counterpart of {@link #useSsl(MqttClientSslConfig)}.
     * 

* Calling {@link MqttClientSslConfigBuilder.Nested#applySslConfig()} on the returned builder has the effect of * extending the current SSL configuration. * * @return the fluent builder for the SSL configuration. * @see #useSsl(MqttClientSslConfig) */ @NotNull MqttClientSslConfigBuilder.Nested useSsl(); /** * Uses WebSocket with the default configuration. * * @return the builder. */ @NotNull B useWebSocketWithDefaultConfig(); /** * Sets the optional {@link MqttClientConfig#getWebSocketConfig() WebSocket configuration}. * * @param webSocketConfig the WebSocket configuration or null to remove any previously set WebSocket * configuration. * @return the builder. */ @NotNull B useWebSocket(@Nullable MqttWebSocketConfig webSocketConfig); /** * Fluent counterpart of {@link #useWebSocket(MqttWebSocketConfig)}. *

* Calling {@link MqttWebSocketConfigBuilder.Nested#applyWebSocketConfig()} on the returned builder has the effect * of extending the current WebSocket configuration. * * @return the fluent builder for the WebSocket configuration. * @see #useWebSocket(MqttWebSocketConfig) */ @NotNull MqttWebSocketConfigBuilder.Nested useWebSocket(); /** * Sets the {@link MqttClientConfig#getExecutorConfig() executor configuration}. * * @param executorConfig the executor configuration. * @return the builder. */ @NotNull B executorConfig(@NotNull MqttClientExecutorConfig executorConfig); /** * Fluent counterpart of {@link #executorConfig(MqttClientExecutorConfig)}. *

* Calling {@link MqttClientExecutorConfigBuilder.Nested#applyExecutorConfig()} on the returned builder has the * effect of extending the current executor configuration. * * @return the fluent builder for the executor configuration. * @see #executorConfig(MqttClientExecutorConfig) */ @NotNull MqttClientExecutorConfigBuilder.Nested executorConfig(); }