org.eclipse.ditto.connectivity.model.ConnectionBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ditto-connectivity-model Show documentation
Show all versions of ditto-connectivity-model Show documentation
Eclipse Ditto is a framework for creating and managing digital twins in the IoT.
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.connectivity.model;
import java.time.Instant;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import org.eclipse.ditto.json.JsonObject;
/**
* A mutable builder for a {@link Connection} with a fluent API.
*/
public interface ConnectionBuilder {
/**
* Sets the identifier to use in the {@code Connection}.
*
* @param id the identifier.
* @return this builder to allow method chaining.
* @throws NullPointerException if {@code id} is {@code null}.
*/
ConnectionBuilder id(ConnectionId id);
/**
* Sets the name to use in the {@code Connection}.
*
* @param name the name.
* @return this builder to allow method chaining.
*/
ConnectionBuilder name(@Nullable String name);
/**
* Sets the connection credentials.
*
* @param credentials the credentials.
* @return this builder.
*/
ConnectionBuilder credentials(@Nullable Credentials credentials);
/**
* Sets the connection credentials in JSON representation.
*
* @param jsonObject credentials in JSON representation.
* @return this builder.
*/
default ConnectionBuilder credentialsFromJson(final JsonObject jsonObject) {
return credentials(Credentials.fromJson(jsonObject));
}
/**
* Set the trusted certificates.
*
* @param trustedCertificates the trusted certificates
* @return this builder
*/
ConnectionBuilder trustedCertificates(@Nullable final String trustedCertificates);
/**
* Sets the URI to use in the {@code Connection}.
*
* @param uri the URI.
* @return this builder to allow method chaining.
* @throws NullPointerException if {@code uri} is {@code null}.
*/
ConnectionBuilder uri(String uri);
/**
* Sets the ConnectionStatus to use in the {@code Connection}.
*
* @param connectionStatus the ConnectionStatus.
* @return this builder to allow method chaining.
* @throws NullPointerException if {@code connectionStatus} is {@code null}.
*/
ConnectionBuilder connectionStatus(ConnectivityStatus connectionStatus);
/**
* Enable/disable fail-over for the {@code Connection}.
*
* @param failoverEnabled if fail-over is enabled for this connection (default {@code true}).
* @return this builder to allow method chaining.
*/
ConnectionBuilder failoverEnabled(boolean failoverEnabled);
/**
* Enable/disable validation of certificates for the {@code Connection}.
*
* @param validateCertificate if server certificates are validated (default {@code true}).
* @return this builder to allow method chaining.
*/
ConnectionBuilder validateCertificate(boolean validateCertificate);
/**
* Set the command processor pool size for the {@code Connection}.
*
* @param processorPoolSize number of command processor actors that will be used at max (default {@code 5}).
* @return this builder to allow method chaining.
* @throws IllegalArgumentException if {@code processorPoolSize} is not positive.
*/
ConnectionBuilder processorPoolSize(int processorPoolSize);
/**
* Adds additional sources to the connection.
*
* @param sources the sources that are added.
* @return this builder to allow method chaining.
* @throws NullPointerException if {@code sources} is {@code null}.
*/
ConnectionBuilder sources(List